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

Cast hash64 value to uint64 before doing operations #42

Merged
merged 2 commits into from
Aug 2, 2022

Conversation

ptrcnull
Copy link
Contributor

Fixes #38

@puzpuzpuz
Copy link
Owner

Hi,

Thanks for the contribution. I'm afraid that this change is not sufficient. All tests should be passing in 32-bit which is not the case for a number of reasons:

$ GOARCH=386 go test .
--- FAIL: TestMap_MissingEntry (0.00s)
panic: unaligned 64-bit atomic operation [recovered]
	panic: unaligned 64-bit atomic operation

goroutine 133 [running]:
testing.tRunner.func1.2({0x813e620, 0x817be18})
	/usr/local/go/src/testing/testing.go:1209 +0x2ab
testing.tRunner.func1(0xbe620f0)
	/usr/local/go/src/testing/testing.go:1212 +0x27d
panic({0x813e620, 0x817be18})
	/usr/local/go/src/runtime/panic.go:1038 +0x1c5
runtime/internal/atomic.panicUnaligned()
	/usr/local/go/src/runtime/internal/atomic/unaligned.go:8 +0x2d
runtime/internal/atomic.Load64(0xbe66004)
	/usr/local/go/src/runtime/internal/atomic/atomic_386.s:225 +0x10
github.com/puzpuzpuz/xsync.(*Map).resizeInProgress(...)
	/home/puzpuzpuz/projects/xsync/map.go:252
github.com/puzpuzpuz/xsync.(*Map).LoadAndDelete(0xbe66000, {0x8152fe5, 0x3})
	/home/puzpuzpuz/projects/xsync/map.go:367 +0x107
github.com/puzpuzpuz/xsync_test.TestMap_MissingEntry(0xbe620f0)
	/home/puzpuzpuz/projects/xsync/map_test.go:59 +0xbb
testing.tRunner(0xbe620f0, 0x815de58)
	/usr/local/go/src/testing/testing.go:1259 +0xe6
created by testing.(*T).Run
	/usr/local/go/src/testing/testing.go:1306 +0x33a
FAIL	github.com/puzpuzpuz/xsync	0.156s
FAIL

@ptrcnull
Copy link
Contributor Author

ah, you're right; i'll try to fix the test failures too

Prevents "unaligned 64-bit atomic operation" on 32-bit
@ptrcnull
Copy link
Contributor Author

ptrcnull commented Aug 2, 2022

(it passes the tests now btw)

$ GOARCH=386 go test .
ok  	github.com/puzpuzpuz/xsync	4.828s

Copy link
Owner

@puzpuzpuz puzpuzpuz left a comment

Choose a reason for hiding this comment

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

Sorry, I was unavailable for a few days. LGTM. Thanks for the contribution!

@puzpuzpuz puzpuzpuz merged commit cae5b9e into puzpuzpuz:main Aug 2, 2022
@ptrcnull ptrcnull deleted the fix-32bit branch August 2, 2022 18:40
@ohdearaugustin
Copy link

@ptrcnull Thank you for your work (=

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.

Doesn't compile on 32bit
3 participants