pgzip: Fix an occasional segfault/panic with pgzip #30
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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() ).