summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortehprofessor <servando@gmail.com>2020-08-06 23:33:17 -0700
committerBjörn Gustavsson <bjorn@erlang.org>2021-02-18 12:04:00 +0100
commitdaaf5e32cf59f026225faca529c6cce2cc17af40 (patch)
tree0e137cf18e3c4f8002163124cd9a18157ec442ae
parent2c37b50ce36dba22ab96110074a33c9037402a14 (diff)
downloaderlang-daaf5e32cf59f026225faca529c6cce2cc17af40.tar.gz
Fix segfault(s) from variadic args on ARM64
Fix for Segfaults on Apple ARM64. Apple silicon does not support re-casting functions with fixed params as variadic, and instead requires the the function pointer to match the signature of the definition. If they do not match arguments will not be correctly marshaled, causing the function implementation to look for parameters in the wrong places. To enable Apple ARM64 support, we must explicitly cast to the correct function signature instead of using varargs `...`. Co-Authored-By: mjc <mjc@kernel.org>
-rw-r--r--erts/emulator/beam/erl_db_util.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/erts/emulator/beam/erl_db_util.c b/erts/emulator/beam/erl_db_util.c
index b708a91371..e0521f7578 100644
--- a/erts/emulator/beam/erl_db_util.c
+++ b/erts/emulator/beam/erl_db_util.c
@@ -1973,7 +1973,7 @@ Eterm db_prog_match(Process *c_p,
Process *tmpp;
Process *current_scheduled;
ErtsSchedulerData *esdp;
- Eterm (*bif)(Process*, ...);
+ BIF_RETTYPE (*bif)(BIF_ALIST);
Eterm bif_args[3];
int fail_label;
#ifdef DMC_DEBUG
@@ -2280,8 +2280,8 @@ restart:
*esp++ = t;
break;
case matchCall0:
- bif = (Eterm (*)(Process*, ...)) *pc++;
- t = (*bif)(build_proc, bif_args);
+ bif = (BIF_RETTYPE (*)(BIF_ALIST)) *pc++;
+ t = (*bif)(build_proc, bif_args, NULL);
if (is_non_value(t)) {
if (do_catch)
t = FAIL_TERM;
@@ -2291,8 +2291,8 @@ restart:
*esp++ = t;
break;
case matchCall1:
- bif = (Eterm (*)(Process*, ...)) *pc++;
- t = (*bif)(build_proc, esp-1);
+ bif = (BIF_RETTYPE (*)(BIF_ALIST)) *pc++;
+ t = (*bif)(build_proc, esp-1, NULL);
if (is_non_value(t)) {
if (do_catch)
t = FAIL_TERM;
@@ -2302,10 +2302,10 @@ restart:
esp[-1] = t;
break;
case matchCall2:
- bif = (Eterm (*)(Process*, ...)) *pc++;
+ bif = (BIF_RETTYPE (*)(BIF_ALIST)) *pc++;
bif_args[0] = esp[-1];
bif_args[1] = esp[-2];
- t = (*bif)(build_proc, bif_args);
+ t = (*bif)(build_proc, bif_args, NULL);
if (is_non_value(t)) {
if (do_catch)
t = FAIL_TERM;
@@ -2316,11 +2316,11 @@ restart:
esp[-1] = t;
break;
case matchCall3:
- bif = (Eterm (*)(Process*, ...)) *pc++;
+ bif = (BIF_RETTYPE (*)(BIF_ALIST)) *pc++;
bif_args[0] = esp[-1];
bif_args[1] = esp[-2];
bif_args[2] = esp[-3];
- t = (*bif)(build_proc, bif_args);
+ t = (*bif)(build_proc, bif_args, NULL);
if (is_non_value(t)) {
if (do_catch)
t = FAIL_TERM;