Conversation
johnny9
marked this pull request as ready for review
September 15, 2026 14:04
johnny9
force-pushed
the
test/upstream-qemu-ubsan
branch
from
September 15, 2026 14:54
2d700e0 to
deb28f3
Compare
mutatrum
reviewed
Sep 15, 2026
| d[7] = s[0]; | ||
| uint8_t reversed[32]; | ||
|
|
||
| for (size_t i = 0; i < 8; i++) { |
Collaborator
There was a problem hiding this comment.
Maybe add a comment that this loop and memcpy will all be compiled away into register operations
Collaborator
Author
There was a problem hiding this comment.
I dug into this and checked the ESP32-S3 assembly. ESP-IDF sets -fno-builtin-memcpy, so the loop was keeping its copy calls.
I restored the unrolled assignments, aligned the midstate buffers, and added a checked fast path using __builtin_memcpy. At -O2, both copies disappear, leaving eight word loads and eight stores. Unaligned buffers keep a safe fallback.
All 105 tests pass with and without UBSan at both -Og and -O2, including mixed alignment and overlapping buffers.
johnny9
force-pushed
the
test/upstream-qemu-ubsan
branch
from
September 15, 2026 17:38
deb28f3 to
a3e5540
Compare
johnny9
added a commit
to johnny9/skot-ESP-Miner
that referenced
this pull request
Sep 16, 2026
Port the relevant fixes from UBSan PR bitaxeorg#1976 (a3e5540), retaining the existing byte-safe target conversion. Validate alignment at compile time and overlapping buffers in the ordinary QEMU suite. Validation: 144 QEMU tests passed; full ESP-IDF firmware build passed.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds a separate UBSan job for QEMU tests, with alignment and shift checks enabled.
Fixes unaligned hash access and allocations for cJSON and Stratum timing records. Firmware and tests use the same cJSON allocator.
Run locally with
bash tools/run_qemu_tests.sh --ubsan.All 105 tests pass with and without UBSan at both
-Ogand-O2, including mixed alignment and overlapping buffers.