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

Fix alignment crash on i386 #150

Merged
merged 1 commit into from
Mar 23, 2015
Merged

Fix alignment crash on i386 #150

merged 1 commit into from
Mar 23, 2015

Conversation

makern
Copy link

@makern makern commented Mar 22, 2015

This fixes a crash on 32bit machines which looks like this:

# ./go --input-raw :80 --output-http 'http://example.com' -verbose
Version: 0.9.2
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x1 pc=0x818acfc]

goroutine 11 [running]:
sync/atomic.AddUint64(0x18640394, 0x1, 0x0, 0x0, 0x0)
        /usr/local/go/src/sync/atomic/asm_386.s:118 +0xc
main.(*HTTPOutput).Worker(0x18640380)
        <snip>/go/src/github.com/buger/gor/output_http.go:140 +0xe1
created by main.(*HTTPOutput).WorkerMaster
        <snip>/go/src/github.com/buger/gor/output_http.go:123 +0x6c

This happens because because of an explicit check for 64bit alignment added to go by [1]. The go compiler however does not guarantee this alignment as discussed in [2] and [3]. As a workaround this pull request moves activeWorkers to be the first element of the struct which is always aligned properly.

[1] https://code.google.com/p/go/source/detail?r=09cc9661f4ee29dca7da92ae8916cefded775bb5&path=/src/pkg/sync/atomic/asm_386.s
[2] golang/go#599
[3] golang/go#3799

@buger
Copy link
Owner

buger commented Mar 23, 2015

Thanks!

buger added a commit that referenced this pull request Mar 23, 2015
Fix alignment crash on i386
@buger buger merged commit a059648 into buger:master Mar 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants