Repository navigation
mem: --mem gives each var its binding line, use lines, last use and move point, and checks uses after a free - #78
Merged
Merged
Conversation
…ove point, and checks uses after a free
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.
--memnow reports what the Polonius borrow checker reads about each variable (rust-lang/polonius,polonius-engine/src/facts.rs), as report facts, not as checks that reject a program.vars[]gaindefAt(var_defined_at, facts.rs:40: the line of its val, var, pattern or param, null when no binder of its def gives the name),uses(var_used_at, facts.rs:37: every line that reads it; a read inside awhilecounts at the loop's last line, because the loop runs again),lastUse,movedAt(path_moved_at_base, facts.rs:72: the last read of an unshared var, else null),binds(how many binders give the name in its def) andassigned.useAfterFree(Poloniuserrors, output/mod.rs:78: a live loan invalidated): a var that can hold a box of region r, read afterr.free()in the def that handles r. It must be empty on every program (thememfailgate check).The design table (each Polonius fact and its srs counterpart) is in the Mem design notes, section M9.
Two false positives found and scoped. Mem keys a var by its def and name, and has no kill at an assignment. So in
prog/scope_shadow_innerthe inner and the outerxmerge (the outer one is read after the inner one's region is freed), and inprog/var_okxsis reassigned off the freed region first. The check now claims a use after free only for a var bound once and never assigned;bindsandassignedshow where it claims nothing. On s2c, 1,448 var nodes merge shadowed binders: one node per binder and a kill at an assignment are filed as follow-up work.Checks:
mem/movesmatch the source by hand.failis empty on all 126 prog tests, the mem tests and s2c.--mem1.952 G -> 2.035 G (+4.3%). The JSON on s2c is 10.5 MB.Mutants (each builds):
last < freea0) and 6 prog tests in memfailbinds == 1guard dropped!assignedguard dropped