Home - Summaries: (main) : (py3.11) : Everything - Nightly builds - Benchmarks - RPython - Builders - About

rlib/test/test_rthread.py::TestUsingBoehm::()::test_gc_locking

self = <rpython.rlib.test.test_rthread.TestUsingBoehm object at 0x000001cac6bbe790>

    @py.test.mark.xfail(platform.machine() == 's390x' or sys.platform == 'darwin',
                        reason='may fail this test under heavy load')
    def test_gc_locking(self):
        import time
        from rpython.rlib.debug import ll_assert
    
        class State:
            pass
        state = State()
    
        class Z:
            def __init__(self, i, j):
                self.i = i
                self.j = j
            def run(self):
                j = self.j
                if self.i > 1:
                    g(self.i-1, self.j * 2)
                    ll_assert(j == self.j, "1: bad j")
                    g(self.i-2, self.j * 2 + 1)
                else:
                    if len(state.answers) % 7 == 5:
                        gc.collect()
                    state.answers.append(self.j)
                ll_assert(j == self.j, "2: bad j")
            run._dont_inline_ = True
    
        def bootstrap():
            # after_extcall() is called before we arrive here.
            # We can't just acquire and release the GIL manually here,
            # because it is unsafe: bootstrap() is called from a rffi
            # callback which checks for and reports exceptions after
            # bootstrap() returns.  The exception checking code must be
            # protected by the GIL too.
            z = state.z
            state.z = None
            state.bootstrapping.release()
            z.run()
            gc_thread_die()
            # before_extcall() is called after we leave here
    
        def g(i, j):
            state.bootstrapping.acquire(True)
            state.z = Z(i, j)
            start_new_thread(bootstrap, ())
    
        def f():
            state.bootstrapping = allocate_lock()
            state.answers = []
            state.finished = 0
    
            g(10, 1)
            done = False
            willing_to_wait_more = 2000
            while not done:
                if not willing_to_wait_more:
                    break
                willing_to_wait_more -= 1
                done = len(state.answers) == expected
    
                print "waitting %d more iterations" % willing_to_wait_more
                time.sleep(0.01)
    
            time.sleep(0.1)
    
            return len(state.answers)
    
        expected = 89
        fn = self.getcompiled(f, [])
>       answers = fn()

rlib\test\test_rthread.py:173: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
translator\c\test\test_genc.py:198: in __call__
    return f(*args, **kwds)
translator\c\test\test_genc.py:145: in f
    err=return_stderr)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <rpython.translator.c.genc.CStandaloneBuilder object at 0x000001cac96c2a30>
args = '', env = None, err = False, expect_crash = False
exe = local('d:\\systemtemp\\pytest\\usession-pytest3.10-455\\testing_2\\testing_2.exe')

    def cmdexec(self, args='', env=None, err=False, expect_crash=False, exe=None):
        assert self._compiled
        if sys.platform == 'win32':
            #Prevent opening a dialog box
            import ctypes
            winapi = ctypes.windll.kernel32
            SetErrorMode = winapi.SetErrorMode
            SetErrorMode.argtypes=[ctypes.c_int]
    
            SEM_FAILCRITICALERRORS = 1
            SEM_NOGPFAULTERRORBOX  = 2
            SEM_NOOPENFILEERRORBOX = 0x8000
            flags = SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX \
                    | SEM_NOOPENFILEERRORBOX
            #Since there is no GetErrorMode, do a double Set
            old_mode = SetErrorMode(flags)
            SetErrorMode(old_mode | flags)
        if env is None:
            envrepr = ''
        else:
            envrepr = ' [env=%r]' % (env,)
            env.update(os.environ)
        if exe is None:
            exe = self.executable_name
        log.cmdexec('%s %s%s' % (exe, args, envrepr))
        res = self.translator.platform.execute(exe, args, env=env)
        if sys.platform == 'win32':
            SetErrorMode(old_mode)
        if res.returncode != 0:
            if expect_crash:
                if type(expect_crash) is int and expect_crash != res.returncode:
                    raise Exception("Returned %d, but expected %d" % (
                        res.returncode, expect_crash))
                return res.out, res.err
            print(res.err, file=sys.stderr)
>           raise Exception("Returned %d" % (res.returncode,))
E           Exception: Returned 2147483651

translator\c\genc.py:318: Exception
builder: rpython-win-x86-64 build #404
test: rlib/test/test_rthread/py/TestUsingBoehm/()/test_gc_locking