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

pgzip: Fix an occasional segfault/panic with pgzip #30

Merged
merged 1 commit into from
Mar 19, 2020

Conversation

ttimonen
Copy link
Contributor

This change fixes a occasional (5-10 out of 1000 test runs) segfault/panic on
sync.Pool struct access. Basically what happens there is that the original code
assigns a zero-value sync.Pool struct to the existing z.dstPool variable.
In general this kind of assignment is safe only if object is not used anymore /
in parallel by anything else. While is kind of true in a sense that none of the
goroutines are using it, in case of sync.Pool the garbage collector does
special management of the data with weak references and in right weather
conditions corrupts internal state (more precisely the sync.Pool.local might
become nil before reading it but after reading a nonzero sync.Pool.localSize;
leading to invalid memory reference in sync.Pool.Get() ).

This change fixes a occasional (5-10 out of 1000 test runs) segfault/panic on
sync.Pool struct access. Basically what happens there is that the original code
assigns a zero-value sync.Pool struct to the existing z.dstPool variable.
In general this kind of assignment is safe only if object is not used anymore /
in parallel by anything else. While is kind of true in a sense that none of the
goroutines are using it, in case of sync.Pool the garbage collector does
special management of the data with weak references and in right weather
conditions corrupts internal state (more precisely the sync.Pool.local might
become nil before reading it but after reading a nonzero sync.Pool.localSize;
leading to invalid memory reference in sync.Pool.Get() ).
@klauspost
Copy link
Owner

Thanks! I will merge if CI completes without problems and likely do a release ASAP.

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