Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package moarvm for openSUSE:Factory checked in at 2021-08-28 22:29:29 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/moarvm (Old) and /work/SRC/openSUSE:Factory/.moarvm.new.1899 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "moarvm" Sat Aug 28 22:29:29 2021 rev:34 rq:914760 version:2021.08 Changes: -------- --- /work/SRC/openSUSE:Factory/moarvm/moarvm.changes 2021-08-27 21:45:14.430064362 +0200 +++ /work/SRC/openSUSE:Factory/.moarvm.new.1899/moarvm.changes 2021-08-28 22:29:52.182022061 +0200 @@ -1,0 +2,6 @@ +Sat Aug 28 10:25:42 UTC 2021 - Stefan Seifert <n...@detonation.org> + +- Backport a fix for segfaults in NativeCall callbacks from moarvm master + Add moarvm-fix-segfaults-in-native-callbacks.diff to be removed on the next release + +------------------------------------------------------------------- New: ---- moarvm-fix-segfaults-in-native-callbacks.diff ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ moarvm.spec ++++++ --- /var/tmp/diff_new_pack.fEhLwQ/_old 2021-08-28 22:29:52.738022679 +0200 +++ /var/tmp/diff_new_pack.fEhLwQ/_new 2021-08-28 22:29:52.742022683 +0200 @@ -19,7 +19,7 @@ %global mvrel 2021.08 Name: moarvm Version: %mvrel -Release: 3.1 +Release: 4.1 Summary: A virtual machine built especially for Rakudo Perl 6 License: Artistic-2.0 Group: Development/Libraries/Other @@ -28,6 +28,7 @@ # PATCH-FIX-OPENSUSE boo#1100677 Patch0: reproducible.patch Patch1: moarvm-fix-memory-leak.diff +Patch2: moarvm-fix-segfaults-in-native-callbacks.diff BuildRequires: perl(ExtUtils::Command) %description @@ -48,6 +49,7 @@ %setup -q -n MoarVM-%{mvrel} %patch0 -p1 %patch1 -p1 +%patch2 -p1 %build perl Configure.pl --prefix=%{_usr} --libdir=%{_libdir} --debug --optimize=3 ++++++ moarvm-fix-segfaults-in-native-callbacks.diff ++++++ commit 7a385a3506cd771ed49715399fbf526bc3ffbd4d Author: Stefan Seifert <n...@detonation.org> Date: Fri Aug 27 14:16:07 2021 +0200 Fix possible access to fromspace in NativeCall callbacks An untimely garbage collection between setting the result object in the callback and unmarshalling of that result object could lead to an outdated pointer in res.o and further to segfaults and other nastiness. Fix by adding res.o to the roots. Callbacks always return objects, so no no special handling of primitive types necessary. diff --git a/src/core/nativecall_dyncall.c b/src/core/nativecall_dyncall.c index 742e53208..95247f0f2 100644 --- a/src/core/nativecall_dyncall.c +++ b/src/core/nativecall_dyncall.c @@ -232,7 +232,7 @@ static char callback_handler(DCCallback *cb, DCArgs *cb_args, DCValue *cb_result /* Build a callsite and arguments buffer. */ args = MVM_malloc(data->num_types * sizeof(MVMRegister)); - num_roots = 0; + num_roots = 1; /* res.o is always in roots */ for (i = 1; i < data->num_types; i++) { MVMObject *type = data->types[i]; MVMint16 typeinfo = data->typeinfos[i]; @@ -330,6 +330,7 @@ static char callback_handler(DCCallback *cb, DCArgs *cb_args, DCValue *cb_result /* Call into a nested interpreter (since we already are in one). Need to * save a bunch of state around each side of this. */ + MVM_gc_root_temp_push(tc, (MVMCollectable **)&(res.o)); cid.invokee = data->target; cid.args = args; cid.cs = data->cs; diff --git a/src/core/nativecall_libffi.c b/src/core/nativecall_libffi.c index a14023930..dd4c7f1ae 100644 --- a/src/core/nativecall_libffi.c +++ b/src/core/nativecall_libffi.c @@ -230,7 +230,7 @@ static void callback_handler(ffi_cif *cif, void *cb_result, void **cb_args, void /* Build a callsite and arguments buffer. */ args = MVM_malloc(data->num_types * sizeof(MVMRegister)); - num_roots = 0; + num_roots = 1; /* res.o is always in roots */ for (i = 1; i < data->num_types; i++) { MVMObject *type = data->types[i]; MVMint16 typeinfo = data->typeinfos[i]; @@ -321,6 +321,7 @@ static void callback_handler(ffi_cif *cif, void *cb_result, void **cb_args, void /* Call into a nested interpreter (since we already are in one). Need to * save a bunch of state around each side of this. */ + MVM_gc_root_temp_push(tc, (MVMCollectable **)&(res.o)); cid.invokee = data->target; cid.args = args; cid.cs = data->cs;