[Fulminate] Fix range map#521
Closed
ZippeyKeys12 wants to merge 1 commit intorems-project:mainfrom
Closed
Conversation
a64ddce to
8632743
Compare
pqwy
added a commit
to pqwy/cn
that referenced
this pull request
Apr 9, 2026
Range queries can not ignore holes... Reported by @ZippeyKeys12 Fixes rems-project#521
pqwy
added a commit
to pqwy/cn
that referenced
this pull request
Apr 9, 2026
Range queries can not ignore holes... Reported by @ZippeyKeys12 Fixes rems-project#521
ZippeyKeys12
pushed a commit
to pqwy/cn
that referenced
this pull request
Apr 11, 2026
Range queries can not ignore holes... Reported by @ZippeyKeys12 Fixes rems-project#521
msaljuk
added a commit
to msaljuk/cn
that referenced
this pull request
Apr 15, 2026
commit d61203a Author: Zain K Aamer <ZippeyKeys12@gmail.com> Date: Tue Apr 14 18:08:19 2026 -0400 [Bennet] Add toggle for extrema skewing (rems-project#534) commit d93c3b2 Author: Zain K Aamer <ZippeyKeys12@gmail.com> Date: Tue Apr 14 15:44:32 2026 -0400 [Bennet] Re-add max depth failures (rems-project#532) commit 2604c07 Author: dk505 <dk505@cam.ac.uk> Date: Thu Apr 9 06:12:59 2026 +0200 [Fulminate] adjust to hole-aware map commit 8b2c69c Author: dk505 <dk505@cam.ac.uk> Date: Thu Apr 9 06:09:41 2026 +0200 [Fulminate] rmap: report gaps Range queries can not ignore holes... Reported by @ZippeyKeys12 Fixes rems-project#521 commit 9766ef5 Author: Dimitrios Economou <dimecon@users.noreply.github.com> Date: Sat Apr 11 15:56:29 2026 +0100 [CN-exec] Fix nested function ghost arguments (rems-project#503) Co-Authored-By: codex codex@openai.com commit 746515e Author: Zain K Aamer <ZippeyKeys12@gmail.com> Date: Thu Apr 9 22:50:56 2026 -0400 [Darcy] Fix rare bug? (rems-project#529) commit 12120f5 Author: Rini Banerjee <26858592+rbanerjee20@users.noreply.github.com> Date: Wed Apr 8 20:07:07 2026 +0100 [Fulminate] Add CLI flag to disable CN statement checking (rems-project#527) commit 8b0654f Author: Rini Banerjee <rbanerjee20@gmail.com> Date: Wed Apr 8 13:27:14 2026 +0100 dune fmt commit 661e929 Author: Rini Banerjee <rbanerjee20@gmail.com> Date: Tue Feb 24 01:07:52 2026 +0000 add todo commit f06b97e Author: Rini Banerjee <rbanerjee20@gmail.com> Date: Mon Feb 23 21:08:06 2026 +0000 first stab at missing ownership self-correction scheme commit b79aa05 Author: Rini Banerjee <rbanerjee20@gmail.com> Date: Mon Feb 23 19:43:30 2026 +0000 pipe new missing ownership correction flag from CLI to Fulm runtime
msaljuk
added a commit
to msaljuk/cn
that referenced
this pull request
Apr 15, 2026
Squashed commit of the following: commit a5d1912 Author: Zain K Aamer <ZippeyKeys12@gmail.com> Date: Wed Apr 15 09:56:06 2026 -0400 [CN-Testing] Fix shuffle (rems-project#538) commit d61203a Author: Zain K Aamer <ZippeyKeys12@gmail.com> Date: Tue Apr 14 18:08:19 2026 -0400 [Bennet] Add toggle for extrema skewing (rems-project#534) commit d93c3b2 Author: Zain K Aamer <ZippeyKeys12@gmail.com> Date: Tue Apr 14 15:44:32 2026 -0400 [Bennet] Re-add max depth failures (rems-project#532) commit 2604c07 Author: dk505 <dk505@cam.ac.uk> Date: Thu Apr 9 06:12:59 2026 +0200 [Fulminate] adjust to hole-aware map commit 8b2c69c Author: dk505 <dk505@cam.ac.uk> Date: Thu Apr 9 06:09:41 2026 +0200 [Fulminate] rmap: report gaps Range queries can not ignore holes... Reported by @ZippeyKeys12 Fixes rems-project#521 commit 9766ef5 Author: Dimitrios Economou <dimecon@users.noreply.github.com> Date: Sat Apr 11 15:56:29 2026 +0100 [CN-exec] Fix nested function ghost arguments (rems-project#503) Co-Authored-By: codex codex@openai.com commit 746515e Author: Zain K Aamer <ZippeyKeys12@gmail.com> Date: Thu Apr 9 22:50:56 2026 -0400 [Darcy] Fix rare bug? (rems-project#529) commit 12120f5 Author: Rini Banerjee <26858592+rbanerjee20@users.noreply.github.com> Date: Wed Apr 8 20:07:07 2026 +0100 [Fulminate] Add CLI flag to disable CN statement checking (rems-project#527) commit 8b0654f Author: Rini Banerjee <rbanerjee20@gmail.com> Date: Wed Apr 8 13:27:14 2026 +0100 dune fmt commit 661e929 Author: Rini Banerjee <rbanerjee20@gmail.com> Date: Tue Feb 24 01:07:52 2026 +0000 add todo commit f06b97e Author: Rini Banerjee <rbanerjee20@gmail.com> Date: Mon Feb 23 21:08:06 2026 +0000 first stab at missing ownership self-correction scheme commit b79aa05 Author: Rini Banerjee <rbanerjee20@gmail.com> Date: Mon Feb 23 19:43:30 2026 +0000 pipe new missing ownership correction flag from CLI to Fulm runtime
msaljuk
added a commit
to msaljuk/cn
that referenced
this pull request
Apr 15, 2026
Squashed commit of the following: commit a5d1912 Author: Zain K Aamer <ZippeyKeys12@gmail.com> Date: Wed Apr 15 09:56:06 2026 -0400 [CN-Testing] Fix shuffle (rems-project#538) commit d61203a Author: Zain K Aamer <ZippeyKeys12@gmail.com> Date: Tue Apr 14 18:08:19 2026 -0400 [Bennet] Add toggle for extrema skewing (rems-project#534) commit d93c3b2 Author: Zain K Aamer <ZippeyKeys12@gmail.com> Date: Tue Apr 14 15:44:32 2026 -0400 [Bennet] Re-add max depth failures (rems-project#532) commit 2604c07 Author: dk505 <dk505@cam.ac.uk> Date: Thu Apr 9 06:12:59 2026 +0200 [Fulminate] adjust to hole-aware map commit 8b2c69c Author: dk505 <dk505@cam.ac.uk> Date: Thu Apr 9 06:09:41 2026 +0200 [Fulminate] rmap: report gaps Range queries can not ignore holes... Reported by @ZippeyKeys12 Fixes rems-project#521 commit 9766ef5 Author: Dimitrios Economou <dimecon@users.noreply.github.com> Date: Sat Apr 11 15:56:29 2026 +0100 [CN-exec] Fix nested function ghost arguments (rems-project#503) Co-Authored-By: codex codex@openai.com commit 746515e Author: Zain K Aamer <ZippeyKeys12@gmail.com> Date: Thu Apr 9 22:50:56 2026 -0400 [Darcy] Fix rare bug? (rems-project#529) commit 12120f5 Author: Rini Banerjee <26858592+rbanerjee20@users.noreply.github.com> Date: Wed Apr 8 20:07:07 2026 +0100 [Fulminate] Add CLI flag to disable CN statement checking (rems-project#527) commit 8b0654f Author: Rini Banerjee <rbanerjee20@gmail.com> Date: Wed Apr 8 13:27:14 2026 +0100 dune fmt commit 661e929 Author: Rini Banerjee <rbanerjee20@gmail.com> Date: Tue Feb 24 01:07:52 2026 +0000 add todo commit f06b97e Author: Rini Banerjee <rbanerjee20@gmail.com> Date: Mon Feb 23 21:08:06 2026 +0000 first stab at missing ownership self-correction scheme commit b79aa05 Author: Rini Banerjee <rbanerjee20@gmail.com> Date: Mon Feb 23 19:43:30 2026 +0000 pipe new missing ownership correction flag from CLI to Fulm runtime
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.
There are bugs that used to be detected, that are no longer flagged since 384f4f3.
I am not that familiar with the code or the data structure, so I asked Claude Code and it gave the report below.
This PR includes its implementation of the first "potential fix".
Claude Code's Report
Analysis: Why commit 384f4f3 broke bug detection
Root Cause:
rmap_find_rangeignores unmapped gapsThe commit replaced the byte-by-byte hash-table ownership tracking with a range-map (
rmap). The newc_ownership_checkhas a fast path that short-circuits based onrmap_find_range, but that function silently ignores unmapped bytes.The fast path in
c_ownership_check(utils.c:507-517)Why
rmap_find_rangeis misleadingIn
rmap.c,find_rangereturnsres_emptyforEMPTYnodes, andres_appendskips empties:So
rmap_find_range(addr, addr+size-1)computes min/max only over bytes present in the rmap. Unmapped bytes are invisible.The failure scenario
Consider a multi-byte access (e.g.,
CN_LOADon a struct field) where:[addr, addr+size-1]are owned atexpected_stack_depthrmap_find_rangereturns{defined=true, min=D, max=D}(only sees mapped bytes)res.min == res.max == expected_stack_depthNO_WILDCARD— skips the byte-by-byte loop that would catch the unmapped bytescn_failureis never called — ownership violation goes undetectedBefore the commit (correct behavior)
CN_LOADlooped byte-by-byte, callingc_ownership_checkfor each individual byte:Each byte was checked against the hash table individually. An unmapped byte returned
NULLfromht_get, yieldingUNMAPPED_VAL, which !=expected_stack_depth, triggeringcn_failure.Confirmation approach (using
--print-seed/--seed)To confirm:
384f4f3bf^(parent), run with--print-seed384f4f3bf, run with--seed=<captured_seed>fprintf(stderr, ...)in c_ownership_check at the fast-path return to confirm it fires where the old code would have calledcn_failure.Potential fix
The fast path needs to verify that the entire range is mapped before trusting the min/max. Options:
rmap_is_fully_covered(k0, k1, map)— returns true only if every byte in the range has an entry. Use this as a precondition for the fast path.rmap_find_rangesemantics — returndefined=falsewhen the range has gaps. But this would breakcn_postcondition_leak_checkandcn_loop_leak_check, which intentionally scan the full address space and want to ignore gaps.