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

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

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

    def test_stack_size(self):
        import time
        from rpython.rlib import rthread
        from rpython.rtyper.lltypesystem import lltype
    
        class State:
            pass
        state = State()
    
        def recurse(n):
            if n > 0:
                return recurse(n-1)+1
            else:
                time.sleep(0.2)      # invokes before/after
                return 0
    
        # recurse a lot
        RECURSION = 19500
        if sys.platform == 'win32':
            # If I understand it correctly:
            # - The stack size "reserved" for a new thread is a compile-time
            #   option (by default: 1Mb).  This is a minimum that user code
            #   cannot control.
            # - set_stacksize() only sets the initially "committed" size,
            #   which eventually requires a larger "reserved" size.
            # - The limit below is large enough to exceed the "reserved" size,
            #   for small values of set_stacksize().
            RECURSION = 150 * 1000
    
        def bootstrap():
            recurse(RECURSION)
            state.count += 1
    
        def entry_point(argv):
            os.write(1, "hello world\n")
            error = rthread.set_stacksize(int(argv[1]))
            if error != 0:
                os.write(2, "set_stacksize(%d) returned %d\n" % (
                    int(argv[1]), error))
                raise AssertionError
            # malloc a bit
            s1 = State(); s2 = State(); s3 = State()
            s1.x = 0x11111111; s2.x = 0x22222222; s3.x = 0x33333333
            # start 3 new threads
            state.count = 0
            ident1 = rthread.start_new_thread(bootstrap, ())
            ident2 = rthread.start_new_thread(bootstrap, ())
            ident3 = rthread.start_new_thread(bootstrap, ())
            # wait for the 3 threads to finish
            while True:
                if state.count == 3:
                    break
                time.sleep(0.1)      # invokes before/after
            # check that the malloced structures were not overwritten
            assert s1.x == 0x11111111
            assert s2.x == 0x22222222
            assert s3.x == 0x33333333
            os.write(1, "done\n")
            return 0
    
>       t, cbuilder = self.compile(entry_point)

translator/c/test/test_standalone.py:1306: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
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 / 312 blocks   (32%)
[rtyper] specializing: 200 / 376 blocks   (53%)
[rtyper] specializing: 300 / 431 blocks   (69%)
[rtyper] specializing: 400 / 435 blocks   (91%)
[rtyper] -=- specialized 435 blocks -=-
[rtyper] -=- specialized 48 more blocks -=-
[rtyper] -=- specialized 9 more blocks -=-
[rtyper] -=- specialized 4 more blocks -=-
[rtyper] specializing: 500 / 521 blocks   (95%)
[rtyper] -=- specialized 25 more blocks -=-
builder: rpython-linux-aarch64 build #534
test: translator/c/test/test_standalone/py/TestThread/()/test_stack_size