Repository navigation
fix: four result and discard leaks (#1091, #1118, #1150, #1167) - #1398
Merged
Merged
Conversation
A match or select thrown away at statement position left its arm value in the temp with nobody to release it. The checker also never recorded the type of a match statement, so the emitter could not tell what the temp held. Closes #1091
The cascade scan refused any match on a result local, so the local fell back to a plain struct release that freed the box and not its payload. A bare arm binding is the box itself with no count, so the local stays the last owner when the arms only read it. Closes #1150
A result box owns its payload but has no destructor, so a struct field or container element that held one freed the box and stranded the payload. A result-typed struct field was not recorded at all, so its box leaked too. A box stored in a holder now takes the payload destructor, and a function that returns a shared box under the box abi hands back its own copy. Closes #1167
…elease # Conflicts: # self-host/bootstrap/ir_driver.ir
…elease # Conflicts: # self-host/bootstrap/ir_driver.ir
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.
Four leak fixes, one commit each. They share one PR because each one regenerates the bootstrap seed, so separate PRs would conflict on it.
matchorselectthrown away at statement position left its arm value in the temp with nothing to release it. The checker also never recorded the type of a statementmatch, so the emitter could not tell what the temp held. The discard now releases the temp for every heap kind when every arm is owned or retained on the way in.matchon a result local, so the local fell back to a plain struct release that freed the box and not its payload. A bare arm binding is the box itself with no count, so the local now cascades when the arms only read it.__result_unshare_*), because every caller that opens a call's box takes the payload's count over. This also fixes an invalid read the box abi had onfwd(rs)!over a list element.Each fix has a leak case under
tests/leaksand a regression case with expected output in the memcheck set. The count checker already flags the discarded-match leak once a program has it, and the new corpus case puts it there. It learned the unshare helper's ownership. It cannot see the #1150 and #1167 leaks, because a plain struct release of a result box looks balanced unless something read the box'sokorerrslot, and the marks do not say a box carries a counted payload. Modeling that needs a new mark and is left for later.Closes #1091
Closes #1118
Closes #1150
Closes #1167