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

Unaligned 64-bit atomic operation error when built for linux #35

Closed
dave-filion opened this issue Sep 5, 2022 · 2 comments
Closed

Unaligned 64-bit atomic operation error when built for linux #35

dave-filion opened this issue Sep 5, 2022 · 2 comments

Comments

@dave-filion
Copy link

Hey!

Was looking for a go lib to handle worker pools (after attempting to make my own with limited success), found this lib and it looked very promising. Seemed to run fine locally (running on Mac OS), but when I built it for our production servers (Ubuntu 18), I encountered this Unaligned 64-bit atomic operation error whenever we try to submit a task to the pool.

Have you encountered this before/am I just doing something wrong? Here is the code on my side:

Pool setup

	maxWorkers := Conf.MaxFetcherWorkers
	workQueueBufferSize := Conf.FetcherWorkQueueBufferSize
	panicHandler := func(err interface{}) {
		l.Logf("Fetcher worker exits from a panic: %v\nStack trace: %s", err, string(debug.Stack()))
	}
	workerPool := pond.New(maxWorkers, workQueueBufferSize, pond.PanicHandler(panicHandler))
	l.Logf("Creating worker pool with max size=%v and workQueueBufferSize=%v", maxWorkers, workQueueBufferSize)

and then submitting:

func submitTaskToWorkerPool(workerPool *pond.WorkerPool, refreshRequest RefreshDispatch, l Logger) {
	workerPool.Submit(func() {
		processRefreshDispatch(refreshRequest, l)
	})
}

Getting error = FetcherProcessQueueResult recover from panic=unaligned 64-bit atomic operation

Build the server like so:

GOOS=linux GOARCH=386 go build ./...

and Go version:

go version go1.18 darwin/amd64

Here's the stack trace:

Sep 05 18:25:26 : runtime/debug.Stack()
Sep 05 18:25:26 :         /usr/local/go/src/runtime/debug/stack.go:24 +0x83
Sep 05 18:25:26 : runtime/debug.PrintStack()
Sep 05 18:25:26 :         /usr/local/go/src/runtime/debug/stack.go:16 +0x1a
Sep 05 18:25:26 : github.com/dave-filion/test-app/lib.FetcherProcessQueueResult.func1()
Sep 05 18:25:26 :         /Users/dfilion/go/src/github.com/dave-filion/test-app/lib/fetcher.go:130 +0x94
Sep 05 18:25:26 : panic({0x94f2e20, 0x9d0ab08})
Sep 05 18:25:26 :         /usr/local/go/src/runtime/panic.go:838 +0x1c3
Sep 05 18:25:26 : runtime/internal/atomic.panicUnaligned()
Sep 05 18:25:26 :         /usr/local/go/src/runtime/internal/atomic/unaligned.go:8 +0x2d
Sep 05 18:25:26 : runtime/internal/atomic.Xadd64(0xc70c1ec, 0x1)
Sep 05 18:25:26 :         /usr/local/go/src/runtime/internal/atomic/atomic_386.s:125 +0x11
Sep 05 18:25:26 : github.com/alitto/pond.(*WorkerPool).submit(0xc70c1b0, 0xc4c9770, 0x1)
Sep 05 18:25:26 :         /Users/dfilion/go/pkg/mod/github.com/alitto/pond@v1.8.1/pond.go:245 +0x83
Sep 05 18:25:26 : github.com/alitto/pond.(*WorkerPool).Submit(...)
Sep 05 18:25:26 :         /Users/dfilion/go/pkg/mod/github.com/alitto/pond@v1.8.1/pond.go:221
Sep 05 18:25:26 : github.com/dave-filion/test-app/lib.submitTaskToWorkerPool(0xc70c1b0, {{0xc71abc0, 0xc}, {0xc91bd88, 0x11}, 0x63163f16, {0xc71abe0, 0xf}, 0x0}, {{0x0, ..
Sep 05 18:25:26 :         /Users/dfilion/go/src/github.com/dave-filion/test-app/lib/fetcher.go:193 +0xc9
Sep 05 18:25:26 : github.com/dave-filion/test-app/lib.FetcherProcessQueueResult({0xc4daf00, 0x7c}, 0xc815490, 0xc70c1b0, {{0x0, 0x0}, {0x0, 0x0}, {0xc8ce580, 0x1b}})
Sep 05 18:25:26 :         /Users/dfilion/go/src/github.com/dave-filion/test-app/lib/fetcher.go:163 +0x6f4
Sep 05 18:25:26 : github.com/dave-filion/test-app/lib.MainFetcherGoRoutine(0xc82d5d0, 0xc70c1b0, 0xc815490, {{0x0, 0x0}, {0x0, 0x0}, {0xc8ce580, 0x1b}})

Any idea what could be happening here? let me know if you need any other details. Thank you!

@dave-filion
Copy link
Author

Ah I think this was my fault! Built using GOARCH=amd64 and it seems to be working fine. Closing issue.

@alitto
Copy link
Owner

alitto commented Sep 5, 2022

Hey @dave-filion! Interesting, first time I see this error. Did some quick research and it appears to be related to a known bug in the sync/atomic package (more details in https://pkg.go.dev/sync/atomic#pkg-note-BUG).
Thanks for reporting anyway!

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

No branches or pull requests

2 participants