Repository navigation
[AUTOMATED] fix(p3,p6): a load of a global after a pointer store prints the value stored before it - #832
Merged
Conversation
mahaloz
force-pushed
the
fix/storealias
branch
6 times, most recently
from
October 3, 2026 00:59
f2e9945 to
0fb6364
Compare
…ts the value stored before it At the new default `indexaliasguard global`, heritage puts an indirect_store INDIRECT on a global range at every STORE into its space (up to 1024 per function), so a load of the global after a pointer store reads the global, a value read before the store keeps its own variable, and the store to the global stays where the binary makes it. RulePropagateCopy keeps a global store's COPY when a LOAD that may read the global follows it (also for the COPY that splitting a shared return block makes of the global's MULTIEQUAL), and kuna_loadorder keeps a pointer load ahead of a later store to a global. These checks act only on a range the STORE guard covered; a range past the budget prints as at `load`. Not fixed: a value computed before a pointer load and stored to the global after it (#871, which needs #825). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
794 of 15,541 functions change on 22 stripped binaries (goto 14,274 to 14,282). The sections on the computed-value checks are replaced by the shared-return-block and guard-budget changes, with the functions each one moves. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
mahaloz
force-pushed
the
fix/storealias
branch
from
October 3, 2026 01:55
0fb6364 to
13d830d
Compare
mahaloz
added a commit
to phix33/kuna
that referenced
this pull request
Oct 3, 2026
Brings in Noelo-Lab#872, Noelo-Lab#832 (indexaliasguard global, now the default), Noelo-Lab#875 (varargforward) and Noelo-Lab#877. Heritage::guard keeps the stackstoreguard branch first and main's global STORE guard as the else branch; spec 03 keeps main's global/full paragraphs and notes the stack guard also runs at global. Counts re-derived (254 settables, corpus 392), catalog fixture recaptured, options.md regenerated, stages baseline re-recorded (1795 = main 1792 + the 3 STACK STORE keys). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
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.
The problem
A global read back after a store through a pointer that may point at it prints the value stored before that store, a value read before such a store prints as a read of the global after it, and a load through the pointer prints after a later store to the global.
With
p == &githe printed functions return 0, 8 and 9. The same happens when the store is on a branch or in a loop, and a store to the global can print behind a pointer store or load the binary makes after it (gi = a; *p = k; touch();printed*a1 = a2; gi = a0; touch();).The fix
option indexaliasguardgets a levelglobal, now the default (off|load|global|full;loadwas the default). Heritage puts anINDIRECTon a global at everySTOREinto its space, the global half of upstream'sHeritage::guardStores. Read-only ranges and stores through the stack pointer are skipped, and a function stops guarding new ranges at 1024INDIRECTs.RulePropagateCopydoes not move a stored value into one of theseINDIRECTs, nor past a pointer load that may read the global (into aMULTIEQUAL, a call'sINDIRECT, or theCOPYthat splitting a shared return block makes), so the store stays where the binary makes it.load.elemptr's index walk follows anINDIRECT's first input, so an element pointer stored to a global keeps its type.p1now printsv1 = gi + 0xf; if (0 <= gi) v1 = gi;,keepprintsv1 = gi; *a0 = a1; return v1;andordprintsv1 = *a0; gi = a1; return v1;.Not fixed: a value computed before a pointer load and stored to the global after it still prints as stored ahead of the load (#871; it needs #825 first), a store before a pointer load is still dropped when the global is stored again (#825), and a function that returns the value it stores to a global prints
void(#843).The tests
kuna-cli/tests/store_alias.rscompiles the printed functions of gcc -O0, gcc -O2 and clang -O2 builds ofstorealias_x86_64.c(30 functions; 28 in the -O0 build, where [AUTOMATED] a store to a global before a pointer load is dropped when the global is stored again #825 drops the first store ofw_deadandw_dead2) with gcc and clang at -O0 and -O2, runs them with every pointer aimed at the global and compares with the binary. Main fails the issue's shapes in every build.w_epi(store, then load, before a shared-O0return),w_big/w_big2(past the guard budget) andw_dead/w_dead2(store, branch load, store again) guard against moving output that main prints right.tests/stages/kuna-storealias.xml: 30 assertions,loadagainst the default. No datatest assertion moved (675/675). PEMAIN and globalpointee now expect the read kept ahead of the store, simdlane and retsplitglobal pinload, and globalvalue Render unknown types as real C types (realtypes, DIV-6) #6 also accepts the widening printed with its product.gotocount goes from 14,274 to 14,282. The classes, with functions checked against the disassembly, are indocs/features/storealias/footprint.md.cf2.elf+2.0% / +1.8%, gzip +3.6% / +5.3%, dash +3.1% / +2.5%, sort +2.1% / +2.0%. gzip again at N=15: +3.8% / +3.2%.Fixes #792
🤖 Generated with Claude Code
https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt