Cherry-pick two fixes from Rhizomatica's tree: AWGN eval-order UB, missing <cstring> - #6
Open
spinkham wants to merge 2 commits into
Open
Cherry-pick two fixes from Rhizomatica's tree: AWGN eval-order UB, missing <cstring>#6spinkham wants to merge 2 commits into
spinkham wants to merge 2 commits into
Conversation
GCC no longer transitively provides memset via the other headers, so Delay.cpp and Path.cpp failed to compile with 'memset was not declared in this scope' (observed with GCC 14 / Debian trixie). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> (cherry picked from commit 0d32135)
pInOut[i] = siggain * pInOut[i++] + acc evaluates the RHS (including the i++ side effect) BEFORE the left-hand subscript under C++17 sequencing rules, so every store landed at pInOut[i+1], overwriting the next input sample before it was read. Any run with --snr produced garbage audio (an OFDM modem decodes 0 frames from it even at SNR 20 with no fading); the pre-C++17 MSVC build this was ported from happened to evaluate the subscript first. Split the increment onto its own statement. Found by cross-validating pathsim against Rhizomatica/mercury's Watterson channel with freedv OFDM data frames as the probe signal. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> (cherry picked from commit f76d1e1)
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.
Two commits cherry-picked verbatim from Rhizomatica/pathsim, authored by Rafael Diniz (authorship preserved;
-xmarkers reference the original hashes). Rhizomatica's tree carries these but doesn't send PRs upstream, so master never got them.1.
build: add missing <cstring> includes— master currently fails to compile on modern GCC (memsetundeclared inDelay.cpp/Path.cpp). This is likely why the other open PRs haven't been easy to verify: the tree doesn't build as-is on current toolchains.2.
fix: C++17 evaluation-order bug destroyed the signal in the AWGN stage—NoiseGen.cpp:Under C++17 sequencing the RHS (including the
i++side effect) evaluates before the left-hand subscript, so every store lands atpInOut[i+1], overwriting the next input sample before it's read. Any--snr/--awgn10run produces garbage: measured on current master, a 1 kHz tone through--awgn10comes out at −24.0 dB SNR with corr(in,out) = −0.001 — the output is uncorrelated noise, not a degraded signal. (The pre-C++17 MSVC build this code was ported from happened to evaluate the subscript first, which is why the original Windows PathSim worked.)With these two commits on top of master, the same probe measures +10.73 dB SNR in the 3 kHz band, corr(in,out) = +0.95 — matching the documented S/N design within convention slack.
Independent of #3 (the Hilbert quadrature fix) — the branches don't overlap; all three are needed for a fully functional build.
🤖 Generated with Claude Code