fix GC bug in FFI
A foreign procedure's data could get GCed before the procedure was called, if the procedure is not otherwise reachable. (Bug found by running tests in GC-stress mode.)
This commit is contained in:
parent
7e27bda44c
commit
e3eed89b1d
|
@ -3369,6 +3369,11 @@ Scheme_Object *ffi_do_call(int argc, Scheme_Object *argv[], Scheme_Object *self)
|
||||||
nargs, ivals, avalues,
|
nargs, ivals, avalues,
|
||||||
offsets, p);
|
offsets, p);
|
||||||
|
|
||||||
|
/* Use `data' to make sure it's kept alive (as far as the GC is concerned)
|
||||||
|
until the foreign call returns: */
|
||||||
|
if ((void*)data == (void*)scheme_true)
|
||||||
|
scheme_signal_error("dummy test suceeded!?");
|
||||||
|
|
||||||
if (save_errno != 0) save_errno_values(save_errno);
|
if (save_errno != 0) save_errno_values(save_errno);
|
||||||
ivals = NULL; /* no need now to hold on to this */
|
ivals = NULL; /* no need now to hold on to this */
|
||||||
for (i=0; i<nargs; i++) { avalues[i] = NULL; } /* no need for these refs */
|
for (i=0; i<nargs; i++) { avalues[i] = NULL; } /* no need for these refs */
|
||||||
|
|
|
@ -2576,6 +2576,11 @@ Scheme_Object *ffi_do_call(int argc, Scheme_Object *argv[], Scheme_Object *self)
|
||||||
nargs, ivals, avalues,
|
nargs, ivals, avalues,
|
||||||
offsets, p);
|
offsets, p);
|
||||||
|
|
||||||
|
/* Use `data' to make sure it's kept alive (as far as the GC is concerned)
|
||||||
|
until the foreign call returns: */
|
||||||
|
if ((void*)data == (void*)scheme_true)
|
||||||
|
scheme_signal_error("dummy test suceeded!?");
|
||||||
|
|
||||||
if (save_errno != 0) save_errno_values(save_errno);
|
if (save_errno != 0) save_errno_values(save_errno);
|
||||||
ivals = NULL; /* no need now to hold on to this */
|
ivals = NULL; /* no need now to hold on to this */
|
||||||
for (i=0; i<nargs; i++) { avalues[i] = NULL; } /* no need for these refs */
|
for (i=0; i<nargs; i++) { avalues[i] = NULL; } /* no need for these refs */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user