Commit 0ee69de
committed
fix(🐛): prevent EXC_BAD_ACCESS in Promise destructor after runtime teardown
When async operations (e.g. fromURI image loads) complete after the JSI runtime has been torn down, the Promise destructor crashes with a null pointer dereference in jsi::Pointer::~Pointer(). This happens because resolve_ and reject_ (jsi::Function members) attempt to release their PointerValue through the now-invalid runtime.
The fix adds an explicit destructor that moves the jsi::Function members to the heap before implicit member destruction runs. After std::move, the member's internal ptr_ is null (per jsi::Pointer's move constructor), so implicit destruction safely skips the runtime access. The heap copies are intentionally leaked (~32 bytes per Promise) since there is no safe way to release JSI pointers without a valid runtime.1 parent c010bb9 commit 0ee69de
2 files changed
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
9 | 18 | | |
10 | 19 | | |
11 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
0 commit comments