[PATCH] jit: Fix test failures with Magritte, SUnit and other routines

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] jit: Fix test failures with Magritte, SUnit and other routines

Holger Freyther
From: Holger Hans Peter Freyther <[hidden email]>

The tests crash when returning to a previous context. In the case of the
Magritte test it is crashing on return to Delay class>>#runDelayProcess.

This appears to occur when resuming an existing image. It is because
the F_XLAT and F_XLAT_REACHABLE flags are cleared on saving of the image.
On image resume the refresh_native_ips method will re-generate the
native code and set the F_XLAT flag for active contexts. As the native
code is not executed the F_XLAT_REACHABLE will not be set. This makes it
possible for maybe_release_xlat to release the native code without
updating the context. This will eventually cause a segmentation fault
as the native code is gone.

The solution appears to be easy. Once the native_ip is updated the
F_XLAT_REACHABLE is set. This way it is guaranteed that the native code
will not be collected.

2013-06-10  Holger Hans Peter Freyther  <[hidden email]>

        * interp-jit.inl: Set the F_XLAT_REACHABLE flag in refresh_native_ips.
---
 libgst/interp-jit.inl |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libgst/interp-jit.inl b/libgst/interp-jit.inl
index 0e8fa27..78fa94c 100644
--- a/libgst/interp-jit.inl
+++ b/libgst/interp-jit.inl
@@ -353,6 +353,10 @@ refresh_native_ips (OOP contextOOP)
   virtualIP = TO_INT (context->ipOffset);
   native_ip =
     _gst_map_virtual_ip (context->method, receiverClass, virtualIP);
+  /* The above might have freshly translated the method for us
+     and the F_XLAT_REACHABLE is not set yet. Set the flag right
+     to assure we can safely return to this method. */
+  context->method->flags |= F_XLAT_REACHABLE;
 
 #ifndef OPTIMIZE
   if (!native_ip)
--
1.7.10.4


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] jit: Fix test failures with Magritte, SUnit and other routines

Paolo Bonzini-2
Il 10/06/2013 03:01, Holger Hans Peter Freyther ha scritto:

> index 0e8fa27..78fa94c 100644
> --- a/libgst/interp-jit.inl
> +++ b/libgst/interp-jit.inl
> @@ -353,6 +353,10 @@ refresh_native_ips (OOP contextOOP)
>    virtualIP = TO_INT (context->ipOffset);
>    native_ip =
>      _gst_map_virtual_ip (context->method, receiverClass, virtualIP);
> +  /* The above might have freshly translated the method for us
> +     and the F_XLAT_REACHABLE is not set yet. Set the flag right
> +     to assure we can safely return to this method. */
> +  context->method->flags |= F_XLAT_REACHABLE;

Awesome!

Paolo

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk