Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_cython_coro_is_coroutine: python: Objects/codeobject.c:771: PyCode_Addr2Line: Assertion `addrq >= 0 && addrq < _PyCode_NBYTES(co)' failed. #574

Open
mgorny opened this issue Oct 14, 2023 · 1 comment

Comments

@mgorny
Copy link

mgorny commented Oct 14, 2023

  • uvloop version: v0.18.0 (5ddf38b), also earier
  • Python version: 3.11.6
  • Platform: Gentoo Linux amd64
  • Can you reproduce the bug with PYTHONASYNCIODEBUG in env?: yes
  • Does uvloop behave differently from vanilla asyncio? How?: n/a

When CPython is built with assertions enabled (i.e. configure --with-assertions), test_cython_coro_is_coroutine is causing a crash:

$ make test
[…]
test_cython_coro_is_coroutine (test_cython.TestCythonIntegration.test_cython_coro_is_coroutine) ... python: Objects/codeobject.c:771: PyCode_Addr2Line: Assertion `addrq >= 0 && addrq < _PyCode_NBYTES(co)' failed.
Backtrace via gdb
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007f67050a2e2f in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007f6705052cc2 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007f670503b4ed in __GI_abort () at abort.c:79
#4  0x00007f670503b415 in __assert_fail_base (fmt=0x7f67051b8b98 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x7f670562f638 "addrq >= 0 && addrq < _PyCode_NBYTES(co)", 
    file=file@entry=0x7f670562f377 "Objects/codeobject.c", line=line@entry=771, 
    function=function@entry=0x7f670562fe50 <__PRETTY_FUNCTION__.12> "PyCode_Addr2Line") at assert.c:92
#5  0x00007f670504b5e2 in __assert_fail (assertion=0x7f670562f638 "addrq >= 0 && addrq < _PyCode_NBYTES(co)", 
    file=0x7f670562f377 "Objects/codeobject.c", line=771, function=0x7f670562fe50 <__PRETTY_FUNCTION__.12> "PyCode_Addr2Line")
    at assert.c:101
#6  0x00007f670538ebb3 in PyCode_Addr2Line (co=0x7f6702fe71b0, addrq=0) at Objects/codeobject.c:771
#7  0x00007f670550ee7c in _PyInterpreterFrame_GetLine (frame=0x7f67004ba3e0) at Python/frame.c:169
#8  0x00007f67053b32e8 in PyFrame_GetLineNumber (f=Frame 0x7f67004ba3e0, for file uvloop/loop.pyx, line ?, in _test_coroutine_1 ())
    at Objects/frameobject.c:43
#9  0x00007f67053b3306 in frame_getlineno (f=Frame 0x7f67004ba3e0, for file uvloop/loop.pyx, line ?, in _test_coroutine_1 (), 
    closure=0x0) at Objects/frameobject.c:50
#10 0x00007f6705395e26 in getset_get (descr=0x7f6704f58840, 
    obj=Frame 0x7f67004ba3e0, for file uvloop/loop.pyx, line ?, in _test_coroutine_1 (), type=<type at remote 0x7f6705785ea0>)
    at Objects/descrobject.c:202
#11 0x00007f67053f8ae5 in _PyObject_GenericGetAttrWithDict (
    obj=Frame 0x7f67004ba3e0, for file uvloop/loop.pyx, line ?, in _test_coroutine_1 (), name='f_lineno', dict=0x0, suppress=0)
    at Objects/object.c:1278
#12 0x00007f67053f8e4b in PyObject_GenericGetAttr (
    obj=Frame 0x7f67004ba3e0, for file uvloop/loop.pyx, line ?, in _test_coroutine_1 (), name='f_lineno') at Objects/object.c:1368
#13 0x00007f67053f7d98 in PyObject_GetAttr (v=Frame 0x7f67004ba3e0, for file uvloop/loop.pyx, line ?, in _test_coroutine_1 (), 
    name='f_lineno') at Objects/object.c:916
#14 0x00007f67054cf45c in _PyEval_EvalFrameDefault (tstate=0x7f67058a9218 <_PyRuntime+166328>, frame=0x7f6705a3ba88, throwflag=0)
    at Python/ceval.c:3452
#15 0x00007f67054bfa5a in _PyEval_EvalFrame (tstate=0x7f67058a9218 <_PyRuntime+166328>, frame=0x7f6705a3b8a8, throwflag=0)
    at ./Include/internal/pycore_ceval.h:73
#16 0x00007f67054e1162 in _PyEval_Vector (tstate=0x7f67058a9218 <_PyRuntime+166328>, func=0x7f67041b42c0, locals=0x0, 
    args=0x7ffffb985bf0, argcount=2, kwnames=0x0) at Python/ceval.c:6425
#17 0x00007f6705385531 in _PyFunction_Vectorcall (func=<function at remote 0x7f67041b42c0>, stack=0x7ffffb985bf0, nargsf=2, 
    kwnames=0x0) at Objects/call.c:393
--Type <RET> for more, q to quit, c to continue without paging--c
#18 0x00007f670538893f in _PyObject_VectorcallTstate (tstate=0x7f67058a9218 <_PyRuntime+166328>, 
    callable=<function at remote 0x7f67041b42c0>, args=0x7ffffb985bf0, nargsf=2, kwnames=0x0) at ./Include/internal/pycore_call.h:92
#19 0x00007f670538914b in method_vectorcall (method=<method at remote 0x7f67031afe40>, args=0x7f6701e5d2b8, nargsf=1, kwnames=0x0)
    at Objects/classobject.c:89
#20 0x00007f6705384e5b in _PyVectorcall_Call (tstate=0x7f67058a9218 <_PyRuntime+166328>, func=0x7f6705388ef7 <method_vectorcall>, 
    callable=<method at remote 0x7f67031afe40>, 
    tuple=(<TextTestResult(failfast=False, failures=[], errors=[], testsRun=122, skipped=[(<Test_AIO_Context(_testMethodName='test_create_server_manual_connection_lost', _outcome=None, _testMethodDoc=None, _cleanups=[], _subtest=None, _type_equality_funcs={<type at remote 0x7f67057889e0>: 'assertDictEqual', <type at remote 0x7f67057874c0>: 'assertListEqual', <type at remote 0x7f670578eb60>: 'assertTupleEqual', <type at remote 0x7f670578de20>: 'assertSetEqual', <type at remote 0x7f670578e160>: 'assertSetEqual', <type at remote 0x7f67057921a0>: 'assertMultiLineEqual'}, loop=None, _check_unclosed_resources_in_debug=True, _BaseTestCase__unhandled_exceptions=[]) at remote 0x7f6702b38590>, 'this seems to be a bug in asyncio'), (<Test_AIO_Context(_testMethodName='test_create_ssl_server_manual_connection_lost', _outcome=None, _testMethodDoc=None, _cleanups=[], _subtest=None, _type_equality_funcs={<type at remote 0x7f67057889e0>: 'assertDictEqual', <type at remote 0x7f67057874c0>: 'assertListEqual', <type at remote 0x7f670578eb...(truncated), kwargs={})
    at Objects/call.c:245
#21 0x00007f6705385233 in _PyObject_Call (tstate=0x7f67058a9218 <_PyRuntime+166328>, callable=<method at remote 0x7f67031afe40>, 
    args=(<TextTestResult(failfast=False, failures=[], errors=[], testsRun=122, skipped=[(<Test_AIO_Context(_testMethodName='test_create_server_manual_connection_lost', _outcome=None, _testMethodDoc=None, _cleanups=[], _subtest=None, _type_equality_funcs={<type at remote 0x7f67057889e0>: 'assertDictEqual', <type at remote 0x7f67057874c0>: 'assertListEqual', <type at remote 0x7f670578eb60>: 'assertTupleEqual', <type at remote 0x7f670578de20>: 'assertSetEqual', <type at remote 0x7f670578e160>: 'assertSetEqual', <type at remote 0x7f67057921a0>: 'assertMultiLineEqual'}, loop=None, _check_unclosed_resources_in_debug=True, _BaseTestCase__unhandled_exceptions=[]) at remote 0x7f6702b38590>, 'this seems to be a bug in asyncio'), (<Test_AIO_Context(_testMethodName='test_create_ssl_server_manual_connection_lost', _outcome=None, _testMethodDoc=None, _cleanups=[], _subtest=None, _type_equality_funcs={<type at remote 0x7f67057889e0>: 'assertDictEqual', <type at remote 0x7f67057874c0>: 'assertListEqual', <type at remote 0x7f670578eb...(truncated), kwargs={})
    at Objects/call.c:328
#22 0x00007f670538532c in PyObject_Call (callable=<method at remote 0x7f67031afe40>, 
    args=(<TextTestResult(failfast=False, failures=[], errors=[], testsRun=122, skipped=[(<Test_AIO_Context(_testMethodName='test_create_server_manual_connection_lost', _outcome=None, _testMethodDoc=None, _cleanups=[], _subtest=None, _type_equality_funcs={<type at remote 0x7f67057889e0>: 'assertDictEqual', <type at remote 0x7f67057874c0>: 'assertListEqual', <type at remote 0x7f670578eb60>: 'assertTupleEqual', <type at remote 0x7f670578de20>: 'assertSetEqual', <type at remote 0x7f670578e160>: 'assertSetEqual', <type at remote 0x7f67057921a0>: 'assertMultiLineEqual'}, loop=None, _check_unclosed_resources_in_debug=True, _BaseTestCase__unhandled_exceptions=[]) at remote 0x7f6702b38590>, 'this seems to be a bug in asyncio'), (<Test_AIO_Context(_testMethodName='test_create_ssl_server_manual_connection_lost', _outcome=None, _testMethodDoc=None, _cleanups=[], _subtest=None, _type_equality_funcs={<type at remote 0x7f67057889e0>: 'assertDictEqual', <type at remote 0x7f67057874c0>: 'assertListEqual', <type at remote 0x7f670578eb...(truncated), kwargs={})
    at Objects/call.c:355
#23 0x00007f67054e4445 in do_call_core (tstate=0x7f67058a9218 <_PyRuntime+166328>, func=<method at remote 0x7f67031afe40>, 
    callargs=(<TextTestResult(failfast=False, failures=[], errors=[], testsRun=122, skipped=[(<Test_AIO_Context(_testMethodName='test_create_server_manual_connection_lost', _outcome=None, _testMethodDoc=None, _cleanups=[], _subtest=None, _type_equality_funcs={<type at remote 0x7f67057889e0>: 'assertDictEqual', <type at remote 0x7f67057874c0>: 'assertListEqual', <type at remote 0x7f670578eb60>: 'assertTupleEqual', <type at remote 0x7f670578de20>: 'assertSetEqual', <type at remote 0x7f670578e160>: 'assertSetEqual', <type at remote 0x7f67057921a0>: 'assertMultiLineEqual'}, loop=None, _check_unclosed_resources_in_debug=True, _BaseTestCase__unhandled_exceptions=[]) at remote 0x7f6702b38590>, 'this seems to be a bug in asyncio'), (<Test_AIO_Context(_testMethodName='test_create_ssl_server_manual_connection_lost', _outcome=None, _testMethodDoc=None, _cleanups=[], _subtest=None, _type_equality_funcs={<type at remote 0x7f67057889e0>: 'assertDictEqual', <type at remote 0x7f67057874c0>: 'assertListEqual', <type at remote 0x7f670578eb...(truncated), kwdict={}, use_tracing=0)
    at Python/ceval.c:7343
#24 0x00007f67054dc36e in _PyEval_EvalFrameDefault (tstate=0x7f67058a9218 <_PyRuntime+166328>, frame=0x7f6705a3b820, throwflag=0)
    at Python/ceval.c:5367
#25 0x00007f67054bfa5a in _PyEval_EvalFrame (tstate=0x7f67058a9218 <_PyRuntime+166328>, frame=0x7f6705a3b820, throwflag=0)
    at ./Include/internal/pycore_ceval.h:73
#26 0x00007f67054e1162 in _PyEval_Vector (tstate=0x7f67058a9218 <_PyRuntime+166328>, func=0x7f67041b44a0, locals=0x0, 
    args=0x7ffffb988310, argcount=2, kwnames=0x0) at Python/ceval.c:6425
#27 0x00007f6705385531 in _PyFunction_Vectorcall (func=<function at remote 0x7f67041b44a0>, stack=0x7ffffb988310, nargsf=2, 
    kwnames=0x0) at Objects/call.c:393
#28 0x00007f6705384968 in _PyObject_FastCallDictTstate (tstate=0x7f67058a9218 <_PyRuntime+166328>, 
    callable=<function at remote 0x7f67041b44a0>, args=0x7ffffb988310, nargsf=2, kwargs=0x0) at Objects/call.c:141
[…]
@fantix
Copy link
Member

fantix commented Oct 22, 2023

This is probably because of a Cython limitation: https://github.com/cython/cython/blob/master/docs/src/userguide/limitations.rst#stack-frames

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants