bbruntime: per-BlitzType release dispatch (re-enables testEmbeddedLists)#56
Merged
Merged
Conversation
reference_map stored only a refcount, and `_bbRelease(ptr, label)`
trusted the caller-supplied label for the destructor dispatch:
if (label == "BBCustom") _bbObjDelete(ptr as BBObj*)
else if (label == "BBList") _bbVectorFree(ptr)
`_bbVectorRelease` (called when an element is removed from a BBList,
or when an outer list iterates its elements during _bbVectorFree)
hardcoded the label as "BBCustom" because it had no way to recover
the static type after the value went through the type-erased
`std::vector<int>`. So:
- For BBObj-only lists (the common case) it worked.
- For lists holding inner BBLists, the outer free called
_bbRelease(innerPtr, "BBCustom"), refcount hit zero, dispatch
ran _bbObjDelete on a `std::vector<int>*` -- read+write into
arbitrary heap. testEmbeddedLists was disabled because of this.
Change reference_map to `map<int, RefSlot>` where RefSlot carries
both count and a const-char* type label stamped at object-creation
time. Add `_bbReferenceTyped(ptr, type)` for sites that know the
static type at registration; `_bbNewVector` now calls it with "BBList".
`_bbRelease` uses the stamped type when present, falls back to the
caller's label otherwise -- BBObj entries that never went through
`_bbReferenceTyped` keep working with the codegen's "BBCustom" label.
Re-enables testEmbeddedLists; full BlitzForge suite + rcce2 server-
module tests pass against this build.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Closes the long-standing deferred finding:
reference_mapstored only a refcount, and_bbRelease(ptr, label)trusted the caller-supplied label for the destructor dispatch:_bbVectorRelease(fired when an element is removed from aBBList, or when an outer list iterates its elements during_bbVectorFree) hardcoded the label as"BBCustom"— it had no way to recover the element's static type once it lived as anintinsidestd::vector<int>. So:_bbRelease(innerPtr, "BBCustom"). Refcount hit zero, dispatch ran_bbObjDeleteon astd::vector<int>*— read+write into arbitrary heap.testEmbeddedListswas disabled because of this.Change
reference_mapbecomesmap<int, RefSlot>whereRefSlot { int count; const char *type; }— the type label is aconst char*to a static literal (never copied, never freed)._bbReferenceTyped(ptr, type)runtime helper for sites that know the static type at registration time._bbNewVectorstamps"BBList"at creation via_bbReferenceTyped._bbReleaseprefers the stamped type when present and falls back to the caller's label otherwise — BBObj entries that never went through_bbReferenceTypedkeep working with the codegen's"BBCustom"label.Test plan
testEmbeddedListsintests/ListTest.bb.test.batsuite passes (all 14 .bb test files).test.bat(the consumer's server-module suite) passes against this build.🤖 Generated with Claude Code