Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix unaligned load error on 32-bit architectures#438

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nhooyr merged 2 commits intocoder:masterfromx0wllaar:fix-netconn-alignment
Mar 7, 2024

Conversation

x0wllaar
Copy link
Contributor

@x0wllaarx0wllaar commentedFeb 26, 2024
edited
Loading

On some 32-bit architectures, 64-bit atomic operations panic when the value is not aligned properly.

In this package, this causes netConn operations to panic when compiling withGOARCH=386, since netConn does atomic operations with int64 values in the netConn struct (namely, with readExpired and writeExpired):

runtime/internal/atomic.panicUnaligned()        .../go1.22/src/runtime/internal/atomic/unaligned.go:8 +0x2druntime/internal/atomic.Load64(0x90a011c)        .../go1.22/src/runtime/internal/atomic/atomic_386.s:225 +0x10nhooyr.io/websocket.(*netConn).read(0x90a00f0, {0x9180000, 0x8000, 0x8000})        .../go/pkg/mod/nhooyr.io/websocket@v1.8.10/netconn.go:157 +0x2anhooyr.io/websocket.(*netConn).Read(0x90a00f0, {0x9180000, 0x8000, 0x8000})        .../go/pkg/mod/nhooyr.io/websocket@v1.8.10/netconn.go:145 +0xb1!!!REST OF THE CALLSTACK SNIPPED!!!

This commit fixes this by moving readExpired and writeExpired to the beginning of the struct, which makes them properly aligned.

I didn't test, but I think this error will also occur on 32-bit ARM (Raspberry Pi Zero) and MIPS32 (a bunch of routers use that, which is a real use case for me), seehttps://pkg.go.dev/sync/atomic#pkg-note-BUG andgrafana/loki#6944

@x0wllaarx0wllaarforce-pushed thefix-netconn-alignment branch 2 times, most recently from3a71544 to4eda6c3CompareFebruary 26, 2024 21:34
On some 32-bit architectures, 64-bit atomic operations panic when thevalue is not aligned properly.In this package, this causes netConn operations to panic when compilingwith GOARCH=386, since netConn does atomic operations with int64 valuesin the netConn struct (namely, with readExpired and writeExpired).This commit fixes this by moving readExpired and writeExpired to thebeginning of the struct, which makes them properly aligned.
@nhooyr
Copy link
Contributor

Ah darn. Could have sworn I fixed this in the past. Thanks@x0wllaar

@nhooyrnhooyrenabled auto-mergeMarch 7, 2024 19:39
@nhooyrnhooyr merged commit65663d1 intocoder:masterMar 7, 2024
nhooyr added a commit that referenced this pull requestMar 7, 2024
Fix unaligned load error on 32-bit architecturesCloses#432
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@x0wllaar@nhooyr

[8]ページ先頭

©2009-2025 Movatter.jp