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

rlib/test/test_rawrefcount_boehm.py::TestBoehmTranslated::()::test_full_translation

self = <rpython.rlib.test.test_rawrefcount_boehm.TestBoehmTranslated object at 0x09801350>

    def test_full_translation(self):
        # Explicit, not leftover state from another test's configure() call:
        # translation bakes in whichever mode is current right now.  boehm's
        # own C-side rawrefcount support was fixed for the prefix layout
        # (see rpython/rlib/src/boehm-rawrefcount.c), so match that here.
        rawrefcount.configure(True)
    
        def make_ob():
            p = W_Root(42)
            ob = rawrefcount._pyobject_alloc()
            rawrefcount.create_link_pypy(p, ob)
            ob.c_ob_refcnt += REFCNT_FROM_PYPY
            assert rawrefcount.from_obj(rawrefcount.PyObject, p) == ob
            assert rawrefcount.to_obj(W_Root, ob) == p
            return ob
    
        prebuilt_p = W_Root(-42)
        prebuilt_ob = rawrefcount._pyobject_alloc(immortal=True)
    
        def entry_point(argv):
            rawrefcount.create_link_pypy(prebuilt_p, prebuilt_ob)
            prebuilt_ob.c_ob_refcnt += REFCNT_FROM_PYPY
            oblist = [make_ob() for i in range(50)]
            rgc.collect()
            deadlist = []
            while True:
                ob = rawrefcount.next_dead(rawrefcount.PyObject)
                if not ob: break
                if ob.c_ob_refcnt != 1:
                    print "next_dead().ob_refcnt != 1"
                    return 1
                deadlist.append(ob)
            if len(deadlist) == 0:
                print "no dead object"
                return 1
            if len(deadlist) < 30:
                print "not enough dead objects"
                return 1
            for ob in deadlist:
                if ob not in oblist:
                    print "unexpected value for dead pointer"
                    return 1
                oblist.remove(ob)
            print "OK!"
            rawrefcount._ob_free(ob)
            return 0
    
        self.config = get_combined_translation_config(translating=True)
        self.config.translation.gc = "boehm"
        self.config.translation.rawrefcount_link_prefix = rawrefcount.RRC_LINK_PREFIX
        t, cbuilder = self.compile(entry_point)
>       data = cbuilder.cmdexec('hi there')

rlib/test/test_rawrefcount_boehm.py:311: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <rpython.translator.c.genc.CStandaloneBuilder object at 0x0b4271f0>
args = 'hi there', env = None, err = False, expect_crash = False
exe = local('/tmp/usession-pypy-HEAD-50/testing_1/testing_1')

    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 1

translator/c/genc.py:318: Exception
---------- Captured stderr call ----------
[rtyper] specializing: 100 / 482 blocks   (20%)
[rtyper] specializing: 200 / 541 blocks   (36%)
[rtyper] specializing: 300 / 541 blocks   (55%)
[rtyper] specializing: 400 / 541 blocks   (73%)
[rtyper] specializing: 500 / 541 blocks   (92%)
[rtyper] -=- specialized 541 blocks -=-
[rtyper] -=- specialized 4 more blocks -=-
[rtyper] -=- specialized 25 more blocks -=-
[rtyper] specializing: 600 / 634 blocks   (94%)
[rtyper] -=- specialized 64 more blocks -=-
[backendopt:inlining] phase with threshold factor: 32.4
[backendopt:inlining] heuristic: rpython.translator.backendopt.inline.inlining_heuristic
[backendopt:inlining] inlined 8 callsites.
[backendopt:malloc] starting malloc removal
[backendopt:malloc] removed 0 simple mallocs in total
[backendopt:mergeifblocks] starting to merge if blocks
[rtyper] specializing: 700 / 724 blocks   (96%)
[rtyper] -=- specialized 90 more blocks -=-
[rtyper] -=- specialized 0 more blocks -=-
[rtyper] -=- specialized 0 more blocks -=-
[backendopt:inlining] phase with threshold factor: 32.4
[backendopt:inlining] heuristic: rpython.translator.backendopt.inline.inlining_heuristic
[backendopt:inlining] inlined 0 callsites.
[backendopt:malloc] starting malloc removal
[backendopt:malloc] removed 0 simple mallocs in total
[backendopt:mergeifblocks] starting to merge if blocks
[c:database] GC transformer: finished helpers
[c:database] GC transformer: finished tables
[c:database] Inlining GC helpers and postprocessing
[c]      434 nodes  [ array: 33  boehm rtti: 19  func: 187  struct: 195 ]
[c:database] Completed
[c:writing] structdef.h
[c:writing] forwarddecl.h
[c:writing] preimpl.h
[c:writing] data_rpython_flowspace.c
[c:writing] data_rpython_memory_gctransform.c
[c:writing] data_rpython_rlib.c
[c:writing] data_rpython_rlib_test.c
[c:writing] data_rpython_rtyper.c
[c:writing] data_rpython_rtyper_lltypesystem.c
[c:writing] data_rpython_translator_c.c
[c:writing] nonfuncnodes.c
[c:writing] data_rpython_rlib_1.c
[c:writing] data_rpython_rlib_test_1.c
[c:writing] implement.c
[c:writing] rpython_flowspace.c
[c:writing] rpython_memory_gctransform.c
[c:writing] rpython_rlib.c
[c:writing] rpython_rlib_test.c
[c:writing] rpython_rtyper.c
[c:writing] rpython_rtyper_lltypesystem.c
[c:writing] rpython_translator.c
[c:writing] rpython_translator_c.c
[platform:execute] make  in /tmp/usession-pypy-HEAD-50/testing_1
[platform:WARNING] testing_1.c: In function ‘RPython_StartupCode’:
[platform:WARNING] testing_1.c:34:9: warning: ‘GC_all_interior_pointers’ is deprecated [-Wdeprecated-declarations]
[platform:WARNING]    34 |         GC_all_interior_pointers = 0;
[platform:WARNING]       |         ^~~~~~~~~~~~~~~~~~~~~~~~
[platform:WARNING] In file included from common_header.h:109,
[platform:WARNING]                  from testing_1.c:1:
[platform:WARNING] /usr/include/gc/gc.h:188:31: note: declared here
[platform:WARNING]   188 | GC_API GC_ATTR_DEPRECATED int GC_all_interior_pointers;
[platform:WARNING]       |                               ^~~~~~~~~~~~~~~~~~~~~~~~
[platform:WARNING] mem.c: In function ‘boehm_gc_startup_code’:
[platform:WARNING] mem.c:120:5: warning: ‘GC_finalizer_notifier’ is deprecated [-Wdeprecated-declarations]
[platform:WARNING]   120 |     GC_finalizer_notifier = &boehm_gc_finalizer_notifier;
[platform:WARNING]       |     ^~~~~~~~~~~~~~~~~~~~~
[platform:WARNING] In file included from common_header.h:109,
[platform:WARNING]                  from mem.c:1:
[platform:WARNING] /usr/include/gc/gc.h:227:54: note: declared here
[platform:WARNING]   227 | GC_API GC_ATTR_DEPRECATED GC_finalizer_notifier_proc GC_finalizer_notifier;
[platform:WARNING]       |                                                      ^~~~~~~~~~~~~~~~~~~~~
[platform:WARNING] mem.c:121:5: warning: ‘GC_finalize_on_demand’ is deprecated [-Wdeprecated-declarations]
[platform:WARNING]   121 |     GC_finalize_on_demand = 1;
[platform:WARNING]       |     ^~~~~~~~~~~~~~~~~~~~~
[platform:WARNING] /usr/include/gc/gc.h:204:31: note: declared here
[platform:WARNING]   204 | GC_API GC_ATTR_DEPRECATED int GC_finalize_on_demand;
[platform:WARNING]       |                               ^~~~~~~~~~~~~~~~~~~~~
[c:cmdexec] /tmp/usession-pypy-HEAD-50/testing_1/testing_1 hi there
mem.c: 50 mallocs left (use PYPY_ALLOC=1 to see the list)

 (somefailed=True in rlib/test/test_rawrefcount_boehm.py)
builder: rpython-linux-x86-32 build #780*
test: rlib/test/test_rawrefcount_boehm.py::TestBoehmTranslated::()::test_full_translation