Commit 1c6cbfc
fix: own native blocks with Block_copy/Block_release
A block returned from a native method is +0 and may still be a stack
block. Interop::GetResult retained it with CFRetain and
ObjectManager::DisposeValue released it with CFRelease, but CFRetain does
not promote a stack block to the heap. By the time the JS wrapper was
finalized during GC the CFRelease ran against a freed stack frame and
crashed in objc_release (EXC_BAD_ACCESS).
Use Block_copy when taking ownership of the returned block (which moves a
stack block to the heap, or bumps the refcount of a heap/global block) and
Block_release as the matching counterpart on disposal.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent e271a77 commit 1c6cbfc
2 files changed
Lines changed: 16 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1055 | 1055 | | |
1056 | 1056 | | |
1057 | 1057 | | |
1058 | | - | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
1059 | 1067 | | |
1060 | 1068 | | |
1061 | 1069 | | |
1062 | | - | |
1063 | | - | |
1064 | 1070 | | |
1065 | 1071 | | |
1066 | 1072 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
115 | 118 | | |
116 | 119 | | |
117 | 120 | | |
| |||
0 commit comments