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

SHA256 is broken in GCC 13 Release builds #1191

Closed
chfast opened this issue May 28, 2023 · 0 comments · Fixed by #1196
Closed

SHA256 is broken in GCC 13 Release builds #1191

chfast opened this issue May 28, 2023 · 0 comments · Fixed by #1196

Comments

@chfast
Copy link
Member

chfast commented May 28, 2023

I has been investigating why evmone's build of silkworm is failing ~300 blockchain tests.

  • The bug is only present in GCC 13 Release build. Both Debug and GCC 12 Release builds are fine.
  • The root cause is related to SHA256. In core_test 3 SHA256 tests are failing.
  • This is unrelated to the selection of the architecture-specific implementation.
  • The returned hash looks like corrupted/uninitialized memory. The hash is different every run.
chfast added a commit that referenced this issue May 29, 2023
Move `w[16]` buffer outside of the outer loop. Otherwise, `w` goes out
of scope in every outer loop iteration and uninitialized memory is used.
This bug has become visible by building with GCC 13 in Release.

I restored the correct location of `w[16]` as in the original
implementation at
https://github.com/amosnier/sha-2/blob/5beabbcc0d872e15a16d51539922dbfabb806316/sha-256.c#L40-L53.
The code was introduced already with the bug in
#113.

Fixes #1191.
@chfast chfast added the bug label May 29, 2023
yperbasis pushed a commit that referenced this issue May 29, 2023
Move `w[16]` buffer outside of the outer loop. Otherwise, `w` goes out
of scope in every outer loop iteration and uninitialized memory is used.
This bug has become visible by building with GCC 13 in Release.

I restored the correct location of `w[16]` as in the original
implementation at
https://github.com/amosnier/sha-2/blob/5beabbcc0d872e15a16d51539922dbfabb806316/sha-256.c#L40-L53.
The code was introduced already with the bug in
#113.

Fixes #1191.
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 a pull request may close this issue.

1 participant