Commit db3a6e2
committed
Fix wrong deallocation management for JSClosure with FinalizationRegistry
In FinalizationRegistry mode, the `swjs_free_host_function` should
be called with the Swift heap object ID, not the JS closure object ID.
The wrong argument was causing:
- Swift closures to be leaked, because FinalizationRegistry attempted
to release a JS object ID that was never registered as a Swift closure.
- Unintended deallocation of unrelated closures when a reused JS object ID
happened to match a valid Swift closure ID by coincidence. This
eventually led to crashes with `The JSClosure has been already released by Swift side.`1 parent 825f947 commit db3a6e2
File tree
2 files changed
+2
-2
lines changed- Plugins/PackageToJS/Templates
- Runtime/src
2 files changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
635 | 635 | | |
636 | 636 | | |
637 | 637 | | |
638 | | - | |
| 638 | + | |
639 | 639 | | |
640 | 640 | | |
641 | 641 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
553 | 553 | | |
554 | 554 | | |
555 | 555 | | |
556 | | - | |
| 556 | + | |
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
| |||
0 commit comments