translator/c/test/test_standalone.py::TestThread::()::test_thread_and_gc
self = <rpython.translator.c.test.test_standalone.TestThread object at 0x000002b6e4863c20>
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:1451:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
translator\c\test\test_standalone.py:1440: in runme
t, cbuilder = self.compile(entry_point, no__thread=no__thread)
translator\c\test\test_standalone.py:1285: in compile
cbuilder.compile()
translator\c\genc.py:341: in compile
extra_opts)
translator\platform\windows.py:574: in execute_makefile
self._handle_error(returncode, stdout, stderr, path.join('make'))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MsvcPlatform cc=cl.exe>, returncode = 2
stdout = '\tcl.exe stdafx.c /c /nologo /MD /O2 -DPYPY_MAKEFILE /Ycstdafx.h /Fpstdafx.pch /FIstdafx.h /I/include /I"D:\\a\\pyp...ython_memory_gc.c(2168): error C2037: left of \'ullTotalPhys\' specifies undefined struct/union \'MEMORYSTATUSEX\'\r\n'
stderr = '\tcl.exe stdafx.c /c /nologo /MD /O2 -DPYPY_MAKEFILE /Ycstdafx.h /Fpstdafx.pch /FIstdafx.h /I/include /I"D:\\a\\pyp...a\\pypy\\pypy\\rpython"\\translator\\c /I"D:\\a\\pypy\\pypy\\rpython"\\rlib\\src\' : return code \'0x2\'\r\nStop.\r\n'
outname = local('c:\\users\\runner~1\\appdata\\local\\temp\\usession-pypy-HEAD-15\\testing_31\\make')
def _handle_error(self, returncode, stdout, stderr, outname):
if returncode != 0:
# Microsoft compilers write compilation errors to stdout
stderr = stdout + stderr
errorfile = outname.new(ext='errors')
errorfile.write(stderr, mode='wb')
if self.log_errors:
stderrlines = stderr.splitlines()
for line in stderrlines:
log.Error(line)
# ^^^ don't use ERROR, because it might actually be fine.
# Also, ERROR confuses lib-python/conftest.py.
> raise CompilationError(stdout, stderr)
E CompilationError: CompilationError(err="""
E cl.exe stdafx.c /c /nologo /MD /O2 -DPYPY_MAKEFILE /Ycstdafx.h /Fpstdafx.pch /FIstdafx.h /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
E stdafx.c
E cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fotesting_31.obj /c testing_31.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
E testing_31.c
E cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fodata_rpython_memory_gc.obj /c data_rpython_memory_gc.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
E data_rpython_memory_gc.c
E cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fodata_rpython_memory_gctransform.obj /c data_rpython_memory_gctransform.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
E data_rpython_memory_gctransform.c
E cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fodata_rpython_rlib.obj /c data_rpython_rlib.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
E data_rpython_rlib.c
E cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fodata_rpython_rtyper.obj /c data_rpython_rtyper.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
E data_rpython_rtyper.c
E cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fodata_rpython_rtyper_lltypesystem.obj /c data_rpython_rtyper_lltypesystem.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
E data_rpython_rtyper_lltypesystem.c
E cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fodata_rpython_translator_c_test.obj /c data_rpython_translator_c_test.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
E data_rpython_translator_c_test.c
E cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fononfuncnodes.obj /c nonfuncnodes.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
E nonfuncnodes.c
E cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fodata_rpython_memory_gc_1.obj /c data_rpython_memory_gc_1.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
E data_rpython_memory_gc_1.c
E cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fodata_rpython_rlib_1.obj /c data_rpython_rlib_1.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
E data_rpython_rlib_1.c
E cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fodata_rpython_rtyper_lltypesystem_1.obj /c data_rpython_rtyper_lltypesystem_1.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
E data_rpython_rtyper_lltypesystem_1.c
E cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Foimplement.obj /c implement.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
E implement.c
E implement.c(198): warning C4133: 'function': incompatible types - from 'MEMORYSTATUSEX *' to 'LPMEMORYSTATUSEX'
E cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Forpython_memory.obj /c rpython_memory.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
E rpython_memory.c
E cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Forpython_memory_gc.obj /c rpython_memory_gc.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
E rpython_memory_gc.c
E rpython_memory_gc.c(2134): error C2027: use of undefined type 'MEMORYSTATUSEX'
E c:\Users\runneradmin\AppData\Local\Temp\usession-pypy-HEAD-15\testing_31\singleheader.h(2221): note: see declaration of 'MEMORYSTATUSEX'
E rpython_memory_gc.c(2160): error C2027: use of undefined type 'MEMORYSTATUSEX'
E c:\Users\runneradmin\AppData\Local\Temp\usession-pypy-HEAD-15\testing_31\singleheader.h(2221): note: see declaration of 'MEMORYSTATUSEX'
E rpython_memory_gc.c(2161): error C2037: left of 'dwLength' specifies undefined struct/union 'MEMORYSTATUSEX'
E rpython_memory_gc.c(2168): error C2037: left of 'ullTotalPhys' specifies undefined struct/union 'MEMORYSTATUSEX'
E NMAKE : fatal error U1077: 'cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Forpython_memory_gc.obj /c rpython_memory_gc.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src' : return code '0x2'
E Stop.
E """)
translator\platform\windows.py:319: CompilationError
---------- Captured stderr call ----------
[platform:msg] Updated environment with vsver 160, using x64 True
[rtyper] specializing: 100 / 239 blocks (41%)
[rtyper] specializing: 300 / 460 blocks (65%)
[rtyper] specializing: 400 / 460 blocks (86%)
[rtyper] -=- specialized 464 blocks -=-
[rtyper] -=- specialized 4 more blocks -=-
[rtyper] -=- specialized 25 more blocks -=-
[rtyper] specializing: 500 / 2947 blocks (16%)
[rtyper] specializing: 700 / 3023 blocks (23%)
[rtyper] specializing: 1100 / 3764 blocks (29%)
[rtyper] specializing: 1300 / 3768 blocks (34%)
[rtyper] specializing: 1600 / 3878 blocks (41%)
[rtyper] specializing: 1800 / 3878 blocks (46%)
[rtyper] specializing: 2000 / 3878 blocks (51%)
[rtyper] specializing: 2200 / 3923 blocks (56%)
[rtyper] specializing: 2400 / 3923 blocks (61%)
[rtyper] specializing: 2600 / 3923 blocks (66%)
[rtyper] specializing: 2800 / 3925 blocks (71%)
[rtyper] specializing: 3000 / 3925 blocks (76%)
[rtyper] specializing: 3200 / 3925 blocks (81%)
[rtyper] specializing: 3400 / 3925 blocks (86%)
[rtyper] specializing: 3600 / 3925 blocks (91%)
[rtyper] specializing: 3800 / 3925 blocks (96%)
[rtyper] -=- specialized 3440 more blocks -=-
[rtyper] specializing: 4000 / 4043 blocks (98%)
[rtyper] -=- specialized 110 more blocks -=-
[backendopt:inlining] phase with threshold factor: 32.4
[backendopt:inlining] heuristic: rpython.translator.backendopt.inline.inlining_heuristic
[backendopt:inlining] inlined 1836 callsites.
[backendopt:malloc] starting malloc removal
[backendopt:malloc] removed 81 simple mallocs in total
[backendopt:mergeifblocks] starting to merge if blocks
[rtyper] -=- specialized 21 more blocks -=-
[rtyper] specializing: 4100 / 4110 blocks (99%)
[rtyper] -=- specialized 46 more blocks -=-
[rtyper] -=- specialized 0 more blocks -=-
[c:database] GC transformer: finished helpers
[rtyper] -=- specialized 62 more blocks -=-
[backendopt:inlining] phase with threshold factor: 32.4
[backendopt:inlining] heuristic: rpython.translator.backendopt.inline.inlining_heuristic
[backendopt:inlining] inlined 4 callsites.
[backendopt:malloc] starting malloc removal
[backendopt:malloc] removed 16 simple mallocs in total
[backendopt:mergeifblocks] starting to merge if blocks
[c:database] GC transformer: finished tables
[gctransform:info] assigned 74 typeids
[gctransform:info] added 123 push/pop stack root instructions
[gctransform:info] inserted 15 write barrier calls
[gctransform:info] inserted 14 write_barrier_from_array calls
[gctransform:info] found 4 static roots
[c:database] Inlining GC helpers and postprocessing
[c] 929 nodes [ array: 147 framework rtti: 23 func: 370 group: 1 struct: 388 ]
[c:database] Completed
[c:writing] structdef.h
[c:writing] forwarddecl.h
[c:writing] preimpl.h
[c:writing] data_rpython_memory_gc.c
[c:writing] data_rpython_memory_gctransform.c
[c:writing] data_rpython_rlib.c
[c:writing] data_rpython_rtyper.c
[c:writing] data_rpython_rtyper_lltypesystem.c
[c:writing] data_rpython_translator_c_test.c
[c:writing] nonfuncnodes.c
[c:writing] data_rpython_memory_gc_1.c
[c:writing] data_rpython_rlib_1.c
[c:writing] data_rpython_rtyper_lltypesystem_1.c
[c:writing] implement.c
[c:writing] rpython_memory.c
[c:writing] rpython_memory_gc.c
[c:writing] rpython_memory_gctransform.c
[c:writing] rpython_rlib.c
[c:writing] rpython_rtyper.c
[c:writing] rpython_rtyper_lltypesystem.c
[c:writing] rpython_translator.c
[c:writing] rpython_translator_c.c
[c:writing] rpython_translator_c_test.c
[platform:execute] nmake in c:\users\runner~1\appdata\local\temp\usession-pypy-HEAD-15\testing_31
[platform:Error] cl.exe stdafx.c /c /nologo /MD /O2 -DPYPY_MAKEFILE /Ycstdafx.h /Fpstdafx.pch /FIstdafx.h /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
[platform:Error] stdafx.c
[platform:Error] cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fotesting_31.obj /c testing_31.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
[platform:Error] testing_31.c
[platform:Error] cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fodata_rpython_memory_gc.obj /c data_rpython_memory_gc.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
[platform:Error] data_rpython_memory_gc.c
[platform:Error] cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fodata_rpython_memory_gctransform.obj /c data_rpython_memory_gctransform.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
[platform:Error] data_rpython_memory_gctransform.c
[platform:Error] cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fodata_rpython_rlib.obj /c data_rpython_rlib.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
[platform:Error] data_rpython_rlib.c
[platform:Error] cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fodata_rpython_rtyper.obj /c data_rpython_rtyper.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
[platform:Error] data_rpython_rtyper.c
[platform:Error] cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fodata_rpython_rtyper_lltypesystem.obj /c data_rpython_rtyper_lltypesystem.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
[platform:Error] data_rpython_rtyper_lltypesystem.c
[platform:Error] cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fodata_rpython_translator_c_test.obj /c data_rpython_translator_c_test.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
[platform:Error] data_rpython_translator_c_test.c
[platform:Error] cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fononfuncnodes.obj /c nonfuncnodes.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
[platform:Error] nonfuncnodes.c
[platform:Error] cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fodata_rpython_memory_gc_1.obj /c data_rpython_memory_gc_1.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
[platform:Error] data_rpython_memory_gc_1.c
[platform:Error] cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fodata_rpython_rlib_1.obj /c data_rpython_rlib_1.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
[platform:Error] data_rpython_rlib_1.c
[platform:Error] cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Fodata_rpython_rtyper_lltypesystem_1.obj /c data_rpython_rtyper_lltypesystem_1.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
[platform:Error] data_rpython_rtyper_lltypesystem_1.c
[platform:Error] cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Foimplement.obj /c implement.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
[platform:Error] implement.c
[platform:Error] implement.c(198): warning C4133: 'function': incompatible types - from 'MEMORYSTATUSEX *' to 'LPMEMORYSTATUSEX'
[platform:Error] cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Forpython_memory.obj /c rpython_memory.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
[platform:Error] rpython_memory.c
[platform:Error] cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Forpython_memory_gc.obj /c rpython_memory_gc.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src
[platform:Error] rpython_memory_gc.c
[platform:Error] rpython_memory_gc.c(2134): error C2027: use of undefined type 'MEMORYSTATUSEX'
[platform:Error] c:\Users\runneradmin\AppData\Local\Temp\usession-pypy-HEAD-15\testing_31\singleheader.h(2221): note: see declaration of 'MEMORYSTATUSEX'
[platform:Error] rpython_memory_gc.c(2160): error C2027: use of undefined type 'MEMORYSTATUSEX'
[platform:Error] c:\Users\runneradmin\AppData\Local\Temp\usession-pypy-HEAD-15\testing_31\singleheader.h(2221): note: see declaration of 'MEMORYSTATUSEX'
[platform:Error] rpython_memory_gc.c(2161): error C2037: left of 'dwLength' specifies undefined struct/union 'MEMORYSTATUSEX'
[platform:Error] rpython_memory_gc.c(2168): error C2037: left of 'ullTotalPhys' specifies undefined struct/union 'MEMORYSTATUSEX'
[platform:Error] NMAKE : fatal error U1077: 'cl.exe /nologo /MD /O2 -DPYPY_MAKEFILE /Yustdafx.h /Fpstdafx.pch /FIstdafx.h /Forpython_memory_gc.obj /c rpython_memory_gc.c /I/include /I"D:\a\pypy\pypy\rpython"\translator\c /I"D:\a\pypy\pypy\rpython"\rlib\src' : return code '0x2'
[platform:Error] Stop.
builder: rpython-win-x86-64 build #765*
test: translator/c/test/test_standalone.py::TestThread::()::test_thread_and_gc