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

Race condition in TestAllocPutThenGet #55

Closed
anthonyfok opened this issue Aug 27, 2019 · 3 comments
Closed

Race condition in TestAllocPutThenGet #55

anthonyfok opened this issue Aug 27, 2019 · 3 comments

Comments

@anthonyfok
Copy link

While investigating #54, I decided to see if adding the -race flag would help, and came across a different intermittent test failure.

--- FAIL: TestAllocPutThenGet (0.00s)
    alloc_test.go:72: cannot fetch written []bytes from pool
FAIL

Test command:

go clean -testcache
while go test -p=1 -race -vet=off github.com/xtaci/smux; do go clean -testcache; done

Thanks!

/cc @rogers0, @LocutusOfBorg

@anthonyfok anthonyfok changed the title Race condition in --- FAIL: TestAllocPutThenGet Race condition in TestAllocPutThenGet Aug 27, 2019
@xtaci
Copy link
Owner

xtaci commented Aug 28, 2019

I think it's a problem of the test function, instead of a race condition.

sync.Pool.Get() does not guarantee the data Put() into the pool will definitely be retrieved in the next Get().
check : https://golang.org/pkg/sync/#Pool.Get

Get selects an arbitrary item from the Pool, removes it from the Pool, and returns it to the caller. Get may choose to ignore the pool and treat it as empty. Callers should not assume any relation between values passed to Put and the values returned by Get.

xtaci added a commit that referenced this issue Aug 28, 2019
@xtaci
Copy link
Owner

xtaci commented Aug 28, 2019

@anthonyfok
Copy link
Author

Thank you so much for your prompt resolution to this issue!
v1.3.5 works great here, and Ubuntu developers are in the process of pulling this new version into Eoan.

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