-
Notifications
You must be signed in to change notification settings - Fork 18k
crypto/sha256: escape analysis of digest.Sum disagrees on different architectures #48055
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
Comments
Unfortunately this test fails on certain architectures. The problem comes down to inconsistencies in the Go escape analysis where specific variables are marked as escaping on certain architectures. The variables escaping to the heap are unfortunately in crypto/sha256, which makes it impossible to fixthis locally in deephash. For now, fix the test by compensating for the allocations that occur from calling sha256.digest.Sum. See golang/go#48055 Fixes #2727 Signed-off-by: Joe Tsai <joetsai@digital-static.net>
Unfortunately this test fails on certain architectures. The problem comes down to inconsistencies in the Go escape analysis where specific variables are marked as escaping on certain architectures. The variables escaping to the heap are unfortunately in crypto/sha256, which makes it impossible to fixthis locally in deephash. For now, fix the test by compensating for the allocations that occur from calling sha256.digest.Sum. See golang/go#48055 Fixes #2727 Signed-off-by: Joe Tsai <joetsai@digital-static.net>
This is because on these systems:
They use the generic version, which make the Other architectures has their own implementation, which does not, e.g, for arm64 go/src/crypto/sha256/sha256block_arm64.go Line 12 in 56c3856
|
This is kind of unfortunate, because the digest clearly does not escape in
That makes callers of It would be better to use a wrapper
The wrapper will get inlined, and escape analysis will see the flow properly. |
Thanks @cuonglm and @randall77. It seems the issue is more specific to |
Change https://golang.org/cl/346209 mentions this issue: |
Unfortunately this test fails on certain architectures. The problem comes down to inconsistencies in the Go escape analysis where specific variables are marked as escaping on certain architectures. The variables escaping to the heap are unfortunately in crypto/sha256, which makes it impossible to fixthis locally in deephash. For now, fix the test by compensating for the allocations that occur from calling sha256.digest.Sum. See golang/go#48055 Fixes #2727 Signed-off-by: Joe Tsai <joetsai@digital-static.net>
Unfortunately this test fails on certain architectures. The problem comes down to inconsistencies in the Go escape analysis where specific variables are marked as escaping on certain architectures. The variables escaping to the heap are unfortunately in crypto/sha256, which makes it impossible to fixthis locally in deephash. For now, fix the test by compensating for the allocations that occur from calling sha256.digest.Sum. See golang/go#48055 Fixes #2727 Signed-off-by: Joe Tsai <joetsai@digital-static.net> (cherry picked from commit 3f1317e)
It seems to me that the result of escape analysis should be independent of the exact target architecture. This may be an assumption that is totally unfounded as my understanding of the escape analyzer is limited.
To reproduce, try building
crypto/sha256
on various architecturesThe following architectures believe that
d0
andtmp
escape to the heap:while the following do not:
Using
GOARCH=arm
as an example,-gcflags="-m=100
prints the relevant information:The tangible effect of this discrepancy is that
sha256.digest.Sum
always allocates on certain architectures.The text was updated successfully, but these errors were encountered: