This repository was archived by the owner on Aug 31, 2021. It is now read-only.
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboard +1Lines changed: 1 addition & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +# Fix crash when using Obj-C FFI on iOS |
Collapse file
Copy file name to clipboardExpand all lines: libscript/src/script-execute.cpp +7-3Lines changed: 7 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -268,7 +268,7 @@ class MCScriptForeignInvocation |
268 | 268 | /* There are different variants of objc_msgSend we need to use |
269 | 269 | * depending on architecture and return type: |
270 | 270 | * struct return |
271 | | - * all: _stret |
| 271 | + * all but arm64: _stret |
272 | 272 | * float return |
273 | 273 | * arm: no difference |
274 | 274 | * i386: _fpret |
@@ -289,7 +289,9 @@ class MCScriptForeignInvocation |
289 | 289 |
|
290 | 290 | ffi_cif *t_cif = (ffi_cif *)p_handler->objc.function_cif; |
291 | 291 | void (*t_objc_msgSend)() = nullptr; |
292 | | -#if defined(__ARM__) |
| 292 | +#if defined(__ARM64__) |
| 293 | + t_objc_msgSend = (void(*)())objc_msgSend; |
| 294 | +#elif defined(__ARM__) |
293 | 295 | if (t_cif->rtype->type == FFI_TYPE_STRUCT) |
294 | 296 | t_objc_msgSend = (void(*)())objc_msgSend_stret; |
295 | 297 | else |
@@ -310,12 +312,14 @@ class MCScriptForeignInvocation |
310 | 312 | t_objc_msgSend = (void(*)())objc_msgSend_fpret; |
311 | 313 | else |
312 | 314 | t_objc_msgSend = (void(*)())objc_msgSend; |
| 315 | +#else |
| 316 | +#error unknown architecture for objc_msgSend |
313 | 317 | #endif |
314 | 318 | /* We must use a wrapper function written in an obj-c++ source file so that |
315 | 319 | * we can capture any obj-c exceptions. */ |
316 | 320 | extern bool MCScriptCallObjCCatchingErrors(ffi_cif*, void (*)(), void *, void **); |
317 | 321 | return MCScriptCallObjCCatchingErrors(t_cif, |
318 | | - (void(*)())objc_msgSend, |
| 322 | + t_objc_msgSend, |
319 | 323 | p_result_slot_ptr, |
320 | 324 | t_objc_values); |
321 | 325 | #else |
|
Collapse file
Copy file name to clipboardExpand all lines: libscript/src/script-instance.cpp +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1147,9 +1147,8 @@ __MCScriptResolveForeignFunctionBindingForObjC(MCScriptInstanceRef p_instance, |
1147 | 1147 | * make. */ |
1148 | 1148 | if (t_valid) |
1149 | 1149 | { |
1150 | | - if (ffi_prep_cif_var(t_cif, |
| 1150 | + if (ffi_prep_cif(t_cif, |
1151 | 1151 | FFI_DEFAULT_ABI, |
1152 | | - 2, |
1153 | 1152 | t_arg_count, |
1154 | 1153 | t_cif_return_type, |
1155 | 1154 | t_cif_arg_types) != FFI_OK) |
|