Skip to content
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

Regression: "unaligned 64-bit atomic operation" on 32-bit systems #156

Closed
arrogantrabbit opened this issue Oct 5, 2023 · 3 comments
Closed
Assignees

Comments

@arrogantrabbit
Copy link

arrogantrabbit commented Oct 5, 2023

Please look at this thread:

https://forum.duplicacy.com/t/duplicacy-3-2-2-crashes-on-arm-32-bit/8024/7

To reproduce: build 32-bit arm version of the library and try to use.

Regression:

  • v1.9.0: no issues
  • v1.12.0: fails.

The proposed solution is to use atomic.AlignedInt64 instead of int64 in the MemoryBackend struct, or reorder len and buf, ideally -- do both, to reduce waste of space on padding.

Quoting analysis from the linked post:

I believe this is an issue in storj.io/uplink, which was upgraded from v1.9.0 to v1.12.0 for CLI 3.2.1: gilbertchen/duplicacy@7cc1b42

This is the line caused the crash:
https://github.com/storj/uplink/blob/c46ff1e3c01a1ef00000e5bf3ae48f4e887f8466/private/storage/streams/buffer/backend.go#L38C31-L38C31

This is the definition of MemoryBackend:

type MemoryBackend struct {
buf []byte
len int64
closed bool
}

If they can simply swap buf and len like this then the error will go away:

type MemoryBackend struct {
  len    int64
  buf    []byte
  closed bool
}
@storj-gerrit
Copy link

storj-gerrit bot commented Oct 5, 2023

Change private/storage/streams/buffer: fix unaligned LoadInt64 mentions this issue.

@egonelbre
Copy link
Member

@arrogantrabbit Thank you for the report and analysis. It seems we forgot to run staticcheck for 32bit arm, which catches such issues.

@egonelbre
Copy link
Member

PS: I created v1.12.1 release that has this issue fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done/Deployed
Development

No branches or pull requests

2 participants