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

Align atomics on ARM32 #11822

Merged
merged 10 commits into from
Apr 13, 2022
Merged

Align atomics on ARM32 #11822

merged 10 commits into from
Apr 13, 2022

Conversation

xacrimon
Copy link
Contributor

@xacrimon xacrimon commented Apr 8, 2022

Fixes #11106 (comment)

Needs backport to v8 and v9

@espadolini espadolini removed the request for review from Tener April 8, 2022 14:53
@Tener
Copy link
Contributor

Tener commented Apr 8, 2022

@xacrimon @espadolini oops, looks like my review wasn't needed after all. Feel free to ignore my approval :-)

Copy link
Collaborator

@zmb3 zmb3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making these pointers is kind of cheating. Why not rearrange the fields to ensure alignment?

@espadolini
Copy link
Contributor

Making these pointers is kind of cheating. Why not rearrange the fields to ensure alignment?

https://cs.opensource.google/go/go/+/refs/tags/go1.18:src/sync/waitgroup.go;l=23-30

@xacrimon
Copy link
Contributor Author

xacrimon commented Apr 8, 2022

@zmb3 Go's spec nor any official docs guarantee that multiple fields types like that will work as far as I am aware. The only guarantee given is that the first field is 64-bit aligned on ARM32 for an allocated struct or type. This is the de-facto way from what I've seen to accomplish this. Even if this somehow works currently, I don't put a lot of trust into the Go compatability guarantees either and I wouldn't expect that to continue working in the future.

@xacrimon
Copy link
Contributor Author

xacrimon commented Apr 8, 2022

On second thought, we could probably get away with not aligning the 32 bit counters and hope that this doesn't break. I do know that it may be required in some cases on some chips but this probably isn't something we should support as it's not ARMv7 compliant anyway.

@xacrimon xacrimon requested a review from zmb3 April 8, 2022 17:42
@xacrimon
Copy link
Contributor Author

xacrimon commented Apr 8, 2022

We do use the allocation pattern in other places. I will post a PR soon since I did just get some ideas for cleaning that up.

@zmb3
Copy link
Collaborator

zmb3 commented Apr 12, 2022

The only guarantee given is that the first field is 64-bit aligned on ARM32 for an allocated struct or type

Right, and if you have multiple 64-bit fields, and you put them together, they'll all be aligned.

This LGTM as-is now.

lib/backend/memory/memory.go Outdated Show resolved Hide resolved
@xacrimon
Copy link
Contributor Author

The only guarantee given is that the first field is 64-bit aligned on ARM32 for an allocated struct or type

Right, and if you have multiple 64-bit fields, and you put them together, they'll all be aligned.

This LGTM as-is now.

I'm not so sure this is guaranteed (at least I couldn't find it documented in the spec or as a part of the stdlib docs) but it doesn't matter for this PR.

@xacrimon xacrimon enabled auto-merge (squash) April 12, 2022 14:09
@xacrimon xacrimon merged commit 17fd4cc into master Apr 13, 2022
@xacrimon xacrimon deleted the joel/fix-heartbeat-arm32 branch April 13, 2022 14:42
xacrimon added a commit that referenced this pull request Apr 13, 2022
@xacrimon xacrimon mentioned this pull request Apr 13, 2022
xacrimon added a commit that referenced this pull request Apr 19, 2022
@webvictim webvictim mentioned this pull request Apr 19, 2022
@webvictim webvictim mentioned this pull request Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Teleport panics with unaligned 64-bit atomic operation on 32bit ARM
5 participants