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

translator/c/test/test_standalone.py::TestThread::()::test_thread_and_gc

self = <rpython.translator.c.test.test_standalone.TestThread object at 0xfffe1ba7c2d0>

    def test_thread_and_gc(self):
        import time, gc
        from rpython.rlib import rthread, rposix
        from rpython.rtyper.lltypesystem import lltype
    
        class State:
            pass
        state = State()
    
        class Cons:
            def __init__(self, head, tail):
                self.head = head
                self.tail = tail
    
        def check_errno(value):
            rposix.set_saved_errno(value)
            for i in range(10000000):
                pass
            assert rposix.get_saved_errno() == value
    
        def bootstrap():
            rthread.gc_thread_start()
            check_errno(42)
            state.xlist.append(Cons(123, Cons(456, None)))
            gc.collect()
            rthread.gc_thread_die()
    
        def new_thread():
            ident = rthread.start_new_thread(bootstrap, ())
            check_errno(41)
            time.sleep(0.5)    # enough time to start, hopefully
            return ident
    
        def entry_point(argv):
            os.write(1, "hello world\n")
            state.xlist = []
            x2 = Cons(51, Cons(62, Cons(74, None)))
            # start 5 new threads
            ident1 = new_thread()
            ident2 = new_thread()
            #
            gc.collect()
            #
            ident3 = new_thread()
            ident4 = new_thread()
            ident5 = new_thread()
            # wait for the 5 threads to finish
            while True:
                gc.collect()
                if len(state.xlist) == 5:
                    break
                time.sleep(0.1)      # invokes before/after
            # check that the malloced structures were not overwritten
            assert x2.head == 51
            assert x2.tail.head == 62
            assert x2.tail.tail.head == 74
            assert x2.tail.tail.tail is None
            # check the structures produced by the threads
            for i in range(5):
                assert state.xlist[i].head == 123
                assert state.xlist[i].tail.head == 456
                assert state.xlist[i].tail.tail is None
                os.write(1, "%d ok\n" % (i+1))
            return 0
    
        def runme(no__thread):
            t, cbuilder = self.compile(entry_point, no__thread=no__thread)
            data = cbuilder.cmdexec('')
            assert data.splitlines() == ['hello world',
                                         '1 ok',
                                         '2 ok',
                                         '3 ok',
                                         '4 ok',
                                         '5 ok']
    
        if SUPPORT__THREAD:
            runme(no__thread=False)
>       runme(no__thread=True)

translator/c/test/test_standalone.py:1407: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
translator/c/test/test_standalone.py:1396: in runme
    t, cbuilder = self.compile(entry_point, no__thread=no__thread)
translator/c/test/test_standalone.py:1240: in compile
    cbuilder.generate_source(defines=cbuilder.DEBUG_DEFINES)
translator/c/genc.py:178: in generate_source
    db = self.build_database()
translator/c/genc.py:102: in build_database
    self.config.translation.reverse_debugger)
translator/c/database.py:64: in __init__
    self.gctransformer = self.gcpolicy.gettransformer(translator, gchooks)
translator/c/gc.py:452: in gettransformer
    return shadowstack.ShadowStackFrameworkGCTransformer(translator, gchooks)
memory/gctransform/framework.py:132: in __init__
    GCClass, GC_PARAMS = choose_gc_from_config(translator.config)
memory/gc/base.py:593: in choose_gc_from_config
    globals(), locals(), [classname])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    """
    # XXX Should find a way to bound the major collection threshold by the
    # XXX total addressable size.  Maybe by keeping some minimarkpage arenas
    # XXX pre-reserved, enough for a few nursery collections?  What about
    # XXX raw-malloced memory?
    
    # XXX try merging old_objects_pointing_to_pinned into
    # XXX old_objects_pointing_to_young (IRC 2014-10-22, fijal and gregor_w)
    import sys
    import os
    import time
    from rpython.rtyper.lltypesystem import lltype, llmemory, llarena, llgroup
    from rpython.rtyper.lltypesystem.lloperation import llop
    from rpython.rtyper.lltypesystem.llmemory import raw_malloc_usage
    from rpython.memory.gc.base import GCBase, MovingGCBase
>   from rpython.memory.gc import env
E     File "/build_dir/rpython-linux-aarch64/build/rpython/memory/gc/env.py", line 423
E   SyntaxError: Non-ASCII character '\xe2' in file /build_dir/rpython-linux-aarch64/build/rpython/memory/gc/env.py on line 423, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

memory/gc/incminimark.py:70: SyntaxError
---------- Captured stderr call ----------
[rtyper] specializing: 100 / 359 blocks   (27%)
[rtyper] specializing: 200 / 398 blocks   (50%)
[rtyper] specializing: 300 / 500 blocks   (60%)
[rtyper] specializing: 400 / 502 blocks   (79%)
[rtyper] specializing: 500 / 504 blocks   (99%)
[rtyper] -=- specialized 504 blocks -=-
[rtyper] -=- specialized 48 more blocks -=-
[rtyper] -=- specialized 9 more blocks -=-
[rtyper] -=- specialized 4 more blocks -=-
[rtyper] -=- specialized 25 more blocks -=-
builder: rpython-linux-aarch64 build #534
test: translator/c/test/test_standalone/py/TestThread/()/test_thread_and_gc