-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix "Go pointer to Go pointer" panics
The Cgo runtime verifies that Go never passes pointers to other Go pointers, which is required for correct garbage collection. Unfortunately, its checks are not perfect, and there are occasional false positives. Our code triggers these false positives if the slice passed to compression functions is in the same memory allocation as Go pointers. This happened when trying to use zstd with another package's Writer type, which has an internal buffer. The tests added in this PR all fail with the following panic. The fix is to ensure the expression unsafe.Pointer(&src[0]) is inside the Cgo call, and not before. This is documented in the following issue: golang/go#14210 (comment) Fixes: ... TODO
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters