Repository navigation
The fix for the field deref, and the bug no origin can see - #4
Merged
Merged
Conversation
field_deref_after_last_use now runs the same shape twice: once with the raw untracked pointer field (-1, as before) and once with the cell behind an OwnedPointer, whose deref borrows the owner, so the struct stays alive through the read and prints 499500 with the drop last. The fix is a type, not a compiler change. plain_store_races is a new uncaught case of a different kind: a task that writes `sum` with a plain load and store. Every task holds mutable access to the same value and the origin only says how long it lives; a Sync-style trait is what would reject this, and Mojo has none. The load-store window is widened and the worker count fixed at 4 so the lost updates are certain rather than likely — ten runs, ten times True. `run` gains a num_workers passthrough for that. 8 passed, 0 failed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015or6oTZmb7EQTXTbALbBXY
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.
Independent of the threads.mojo typed
parallel_forPR; this one builds against 0.2.2 as before.The fix, demonstrated
tests/uncaught/field_deref_after_last_use.mojonow runs the same shape twice. The rawPointer[Int64, MutUntrackedOrigin]field still reads-1after the struct is destroyed; the cell behind anOwnedPointer[Int64]reads499500, becauseOwnedPointer.__getitem__returns a ref that borrows the pointer, which borrows the struct. Verified, not argued: the harness checks the five lines in order, withOwned droppedlast.The race
tests/uncaught/plain_store_races.mojo: a task doingseen = t[].sum; …; t[].sum = seen + i. Compiles clean, loses updates every run. It is not a lifetime bug — the origin says only how longtotalslives — and it is the case a Sync-style trait would catch; Mojo has none, so it goes in the uncaught set. The load–store window is widened to ~20 µs andrungets anum_workerspassthrough pinned at 4, so the outcome does not depend on the runner's core count (10/10 locally).README: the tables gain the rows, and a closing paragraph sorts the four uncaught cases into three lifetime bugs with fixes that exist today, and one that needs a trait that does not.
pixi run check: 8 passed, 0 failed.🤖 Generated with Claude Code
https://claude.ai/code/session_015or6oTZmb7EQTXTbALbBXY