Skip to content

fix: four result and discard leaks (#1091, #1118, #1150, #1167) - #1398

Merged
kacy merged 6 commits into
mainfrom
fix-discarded-forms-release
Nov 14, 2026
Merged

kacy merged 6 commits into
mainfrom
fix-discarded-forms-release

Conversation

@kacy

@kacy kacy commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Four leak fixes, one commit each. They share one PR because each one regenerates the bootstrap seed, so separate PRs would conflict on it.

Each fix has a leak case under tests/leaks and 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's ok or err slot, 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

kacy added 6 commits November 14, 2026 15:55
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 leak in #1118 was fixed when assertions began releasing their owned
arguments. This case keeps it from coming back.

Closes #1118
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
@kacy
kacy merged commit d1a13ef into main Nov 14, 2026
4 checks passed
@kacy
kacy deleted the fix-discarded-forms-release branch November 14, 2026 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant