Skip to content

BridgeJS: Fix SwiftHeapObject finalization registry leaks and double release#648

Merged
kateinoigakukun merged 1 commit intomainfrom
katei/956f-bridgejs-fix-swi
Feb 18, 2026
Merged

BridgeJS: Fix SwiftHeapObject finalization registry leaks and double release#648
kateinoigakukun merged 1 commit intomainfrom
katei/956f-bridgejs-fix-swi

Conversation

@kateinoigakukun
Copy link
Member

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes two critical issues in BridgeJS's SwiftHeapObject finalization:

  1. Memory leak from creating a new FinalizationRegistry instance for each object
  2. Double-release vulnerability when release() is called multiple times

Changes:

  • Refactored SwiftHeapObject to use a shared FinalizationRegistry with state-based tracking
  • Made release() method idempotent to prevent double-release issues
  • Added test coverage for idempotent release behavior and proper finalization

Reviewed changes

Copilot reviewed 25 out of 27 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift Updated SwiftHeapObject template to use shared finalization registry and state-based tracking
Tests/prelude.mjs Added test for idempotent release() behavior
Tests/BridgeJSRuntimeTests/SwiftClassSupportTests.swift Added async test for proper finalization and deallocation
Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift Generated code for gc() function binding
Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json JSON schema for gc() function
Plugins/BridgeJS/Tests/BridgeJSToolTests/Snapshots/BridgeJSLinkTests/*.js (23 files) Snapshot test files that should reflect the updated SwiftHeapObject implementation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 27 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kateinoigakukun kateinoigakukun merged commit ef3634d into main Feb 18, 2026
18 checks passed
@kateinoigakukun kateinoigakukun deleted the katei/956f-bridgejs-fix-swi branch February 18, 2026 07:01
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.

1 participant

Comments