-
Notifications
You must be signed in to change notification settings - Fork 639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
panic: 64bit unaligned in arm32 #577
Comments
It should a known issue of golang. FYI. https://pkg.go.dev/sync/atomic#pkg-note-BUG |
@nekohasekai the arch is arm32, what's the OS? |
@ahrtr Nexus 7 2013 Android 7.1.2 |
thx for the feedback. It seems a known issue.
|
Do you have any plans to make it 64bit aligned? This problem does not exist in the stable version of bbolt, and there are a large number of users on these 32-bit devices. |
|
It does not exist in 1.3.7. Here is a simple way to reproduce this issue on Linux amd64 using Code: // cmd/bug/main.go
package main
import (
"os"
"go.etcd.io/bbolt"
)
func main() {
db, _ := bbolt.Open("test.db", 0600, &bbolt.Options{})
defer db.Close()
defer os.RemoveAll("test.db")
db.Batch(func(tx *bbolt.Tx) error {
tx.CreateBucketIfNotExists([]byte("test"))
return nil
})
} GOOS=linux GOARCH=arm go build ./cmd/bug
qemu-arm ./bug |
It seems that it's related to #373 |
It is introduced in 8ebdaf8 |
Confirmed that it has nothing to do with #516. Instead, it's caused by #373. After I partially reverted the change in #373 as below, then couldn't reproduce this issue anymore.
|
@nekohasekai could you try #582? |
Confirm fixed. |
Eventually I understood the reason why the issue couldn't be reproduced even it still contains the change in #373. Because one field " Adding " |
You can either migrate atomic calls to int64 variables to atomic.Int64 structs (requires a higher version of Golang, in older versions you can use the inefficient atomic.Value), or change the embedding method of the entire structure from struct to pointer. |
Using The #582 seems to be the simplest and safest solution. The only concern is it removes some public methods (see below), which were introduced in #373, and has already included in v1.3.7. They were added not long ago (about 9 months ago), and it might be fine. We need to add a breaking change item in the changelog though. Lines 677 to 794 in 233156a
|
@ahrtr we could also re-arrange the struct a bit for those things to be aligned again. It's certainly safer than to worry about which part of the stats need to take a lock or not. The variables that need to be aligned for this can be declared at the top of the struct, so it's not even a big change. |
This is a good point. Refer to the second solution #584 |
yep, good one and less risky :) Thanks! |
thx @tjungblu Verified that #584 fixed this issue using |
Resolved in v1.3.8 |
Version: f3bb364
Related code:
bbolt/tx.go
Lines 26 to 43 in ef06562
The text was updated successfully, but these errors were encountered: