[pypy-commit] pypy default: A failing test based on issue #2132.

arigo noreply at buildbot.pypy.org
Sat Oct 10 23:04:37 CEST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r80104:004a5d649ed9
Date: 2015-10-10 23:04 +0200
http://bitbucket.org/pypy/pypy/changeset/004a5d649ed9/

Log:	A failing test based on issue #2132.

diff --git a/rpython/jit/metainterp/test/test_exception.py b/rpython/jit/metainterp/test/test_exception.py
--- a/rpython/jit/metainterp/test/test_exception.py
+++ b/rpython/jit/metainterp/test/test_exception.py
@@ -2,6 +2,7 @@
 from rpython.jit.metainterp.test.support import LLJitMixin
 from rpython.rlib.jit import JitDriver, dont_look_inside
 from rpython.rlib.rarithmetic import ovfcheck, LONG_BIT, intmask
+from rpython.rlib.objectmodel import keepalive_until_here
 from rpython.jit.codewriter.policy import StopAtXPolicy
 from rpython.rtyper.lltypesystem import lltype, rffi
 
@@ -656,6 +657,38 @@
         res = self.interp_operations(f, [5], backendopt=True)
         assert res == 5
 
+    def test_guard_no_exception_incorrectly_removed_from_bridge(self):
+        myjitdriver = JitDriver(greens=[], reds=['i'])
+        @dont_look_inside
+        def do(n):
+            if n > 7:
+                raise ValueError
+            if n > 1:
+                return n
+            raise IndexError
+        def f(i):
+            while i > 0:
+                myjitdriver.jit_merge_point(i=i)
+                f = str(i) + str(i)
+                # ^^^ this sticks a CALL_R in the resume data, inserted
+                # at the start of a bridge *before* the guard_no_exception.
+                # Some optimization step then thinks, correctly, that the
+                # CALL_R cannot raise and kills the guard_no_exception...
+                # As a result, the final IndexError we get for i == 1 is
+                # not caught here and escapes.  It causes issue #2132.
+                try:
+                    do(i)
+                except ValueError:
+                    pass
+                except IndexError:
+                    pass
+                i -= 1
+                keepalive_until_here(f)
+            return 10101
+        assert f(14) == 10101
+        res = self.meta_interp(f, [14])
+        assert res == 10101
+
 
 class MyError(Exception):
     def __init__(self, n):


More information about the pypy-commit mailing list