Skip to content

swiftkit: Invalidate Java wrappers after destroy - #972

Open
100lalitahegde-eng wants to merge 2 commits into
swiftlang:mainfrom
100lalitahegde-eng:fix-85-invalidate-after-destroy
Open

100lalitahegde-eng wants to merge 2 commits into
swiftlang:mainfrom
100lalitahegde-eng:fix-85-invalidate-after-destroy

Conversation

@100lalitahegde-eng

Copy link
Copy Markdown

Resolves #85

Generated methods already call $ensureAlive(), but $memorySegment() and $memoryAddress() still returned the original pointer after destroy. Those accessors now refuse a destroyed instance, and the stored segment or address is cleared in the FFM and JNI wrappers so Java code can't reach freed Swift memory.

I added tests that close a confined arena and check the accessors throw, and ran :SwiftKitCore:test, :SwiftKitFFM:test, and swift test --filter JExtractSwiftTests.

Generated methods already call $ensureAlive() once the cleanup's
destroyed flag is set, but $memorySegment() and $memoryAddress() still
returned the original pointer. Those accessors now refuse a destroyed
instance, and the stored segment or address is cleared so Java code
cannot reach freed Swift memory.

Resolves swiftlang#85

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalidate Java wrapper when we destroy() an underlying swift instance

1 participant