mcfletch / pyopengl

Repository for the PyOpenGL Project
Other
314 stars 97 forks source link

accelerate: python: Objects/memoryobject.c:924: PyMemoryView_GetContiguous: Assertion `buffertype == PyBUF_READ || buffertype == PyBUF_WRITE' failed. #105

Open mgorny opened 10 months ago

mgorny commented 10 months ago

When running the test suite with "accelerate" enabled and Python built with assertions enabled (--with-assertions), the test suite crashes with failed assertion in the C extension:

$ tox -e py311-num1-accel1
py311-num1-accel1: install_deps> python -I -m pip install numpy pip ./accelerate -r /tmp/pyopengl/test-requirements.txt
.pkg: install_requires> python -I -m pip install 'setuptools>=42.0'
.pkg: _optional_hooks> python /usr/lib/python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta
.pkg: get_requires_for_build_editable> python /usr/lib/python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta
.pkg: install_requires_for_build_editable> python -I -m pip install wheel
.pkg: build_editable> python /usr/lib/python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta
py311-num1-accel1: install_package> python -I -m pip install --force-reinstall --no-deps /tmp/pyopengl/.tox/.tmp/package/1/PyOpenGL-3.1.7-0.editable-py3-none-any.whl
py311-num1-accel1: commands[0]> python -m pytest -sv -rxXs tests/ accelerate/tests
========================================================= test session starts =========================================================
platform linux -- Python 3.11.6, pytest-7.4.3, pluggy-1.3.0 -- /tmp/pyopengl/.tox/py311-num1-accel1/bin/python
cachedir: .tox/py311-num1-accel1/.pytest_cache
rootdir: /tmp/pyopengl
collecting ... pygame 2.5.2 (SDL 2.28.2, Python 3.11.6)
Hello from the pygame community. https://www.pygame.org/contribute.html
collected 119 items / 1 skipped                                                                                                       

tests/test_arraydatatype.py::TestCoreDatatype::test_arrayPointer PASSED
tests/test_arraydatatype.py::TestCoreDatatype::test_array_subclass PASSED
tests/test_arraydatatype.py::TestCoreDatatype::test_buffer_api_basic PASSED
tests/test_arraydatatype.py::TestCoreDatatype::test_byte_count PASSED
tests/test_arraydatatype.py::TestCoreDatatype::test_byte_count_numpy PASSED
python: Objects/memoryobject.c:924: PyMemoryView_GetContiguous: Assertion `buffertype == PyBUF_READ || buffertype == PyBUF_WRITE' failed.
Fatal Python error: Aborted

Current thread 0x00007f1995b0c740 (most recent call first):
  File "/tmp/pyopengl/tests/test_arraydatatype.py", line 200 in test_bytearray_support
  File "/usr/lib/python3.11/unittest/case.py", line 579 in _callTestMethod
  File "/usr/lib/python3.11/unittest/case.py", line 623 in run
  File "/usr/lib/python3.11/unittest/case.py", line 678 in __call__
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/_pytest/unittest.py", line 333 in runtest
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/_pytest/runner.py", line 169 in pytest_runtest_call
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/pluggy/_callers.py", line 77 in _multicall
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/pluggy/_manager.py", line 115 in _hookexec
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/pluggy/_hooks.py", line 493 in __call__
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/_pytest/runner.py", line 262 in <lambda>
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/_pytest/runner.py", line 341 in from_call
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/_pytest/runner.py", line 261 in call_runtest_hook
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/_pytest/runner.py", line 222 in call_and_report
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/_pytest/runner.py", line 133 in runtestprotocol
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/_pytest/runner.py", line 114 in pytest_runtest_protocol
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/pluggy/_callers.py", line 77 in _multicall
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/pluggy/_manager.py", line 115 in _hookexec
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/pluggy/_hooks.py", line 493 in __call__
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/_pytest/main.py", line 350 in pytest_runtestloop
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/pluggy/_callers.py", line 77 in _multicall
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/pluggy/_manager.py", line 115 in _hookexec
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/pluggy/_hooks.py", line 493 in __call__
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/_pytest/main.py", line 325 in _main
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/_pytest/main.py", line 271 in wrap_session
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/_pytest/main.py", line 318 in pytest_cmdline_main
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/pluggy/_callers.py", line 77 in _multicall
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/pluggy/_manager.py", line 115 in _hookexec
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/pluggy/_hooks.py", line 493 in __call__
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/_pytest/config/__init__.py", line 169 in main
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/_pytest/config/__init__.py", line 192 in console_main
  File "/tmp/pyopengl/.tox/py311-num1-accel1/lib/python3.11/site-packages/pytest/__main__.py", line 5 in <module>
  File "<frozen runpy>", line 88 in _run_code
  File "<frozen runpy>", line 198 in _run_module_as_main

Extension modules: pygame.base, pygame.constants, pygame.rect, pygame.rwobject, pygame.surflock, pygame.bufferproxy, pygame.math, pygame.surface, pygame.display, pygame.draw, pygame.event, pygame.imageext, pygame.image, pygame.joystick, pygame.key, pygame.mouse, pygame.time, pygame.mask, pygame.pixelcopy, pygame.transform, pygame.font, pygame.mixer_music, pygame.mixer, pygame.scrap, numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, OpenGL_accelerate.errorchecker, OpenGL_accelerate.wrapper, OpenGL_accelerate.formathandler, OpenGL_accelerate.arraydatatype, OpenGL_accelerate.latebind, OpenGL_accelerate.vbo, psutil._psutil_linux, psutil._psutil_posix, OpenGL_accelerate.numpy_formathandler, OpenGL_accelerate.buffers_formathandler (total: 47)
tests/test_arraydatatype.py::TestCoreDatatype::test_bytearray_support py311-num1-accel1: exit -6 (5.79 seconds) /tmp/pyopengl> python -m pytest -sv -rxXs tests/ accelerate/tests pid=399567
.pkg: _exit> python /usr/lib/python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta
  py311-num1-accel1: FAIL code -6 (57.62=setup[51.84]+cmd[5.79] seconds)
  evaluation failed :( (58.29 seconds)

Top of the backtrace:

(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007f19952a2e2f in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007f1995252cc2 in __GI_raise (sig=6) at ../sysdeps/posix/raise.c:26
#3  0x00007f199577ed3e in faulthandler_fatal_error (signum=6) at ./Modules/faulthandler.c:384
#4  <signal handler called>
#5  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#6  0x00007f19952a2e2f in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#7  0x00007f1995252cc2 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#8  0x00007f199523b4ed in __GI_abort () at abort.c:79
#9  0x00007f199523b415 in __assert_fail_base (fmt=0x7f19953b8b98 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x7f1995843cb8 "buffertype == PyBUF_READ || buffertype == PyBUF_WRITE", 
    file=file@entry=0x7f1995843a31 "Objects/memoryobject.c", line=line@entry=924, 
    function=function@entry=0x7f1995845280 <__PRETTY_FUNCTION__.22> "PyMemoryView_GetContiguous") at assert.c:92
#10 0x00007f199524b5e2 in __assert_fail (assertion=0x7f1995843cb8 "buffertype == PyBUF_READ || buffertype == PyBUF_WRITE", 
    file=0x7f1995843a31 "Objects/memoryobject.c", line=924, 
    function=0x7f1995845280 <__PRETTY_FUNCTION__.22> "PyMemoryView_GetContiguous") at assert.c:101
#11 0x00007f19955eb174 in PyMemoryView_GetContiguous (obj=<bytearray at remote 0x7f198bf7e070>, buffertype=60, order=67 'C')
    at Objects/memoryobject.c:924
#12 0x00007f198fa96447 in __pyx_f_17OpenGL_accelerate_21buffers_formathandler_17MemoryviewHandler_c_as_memoryview (
    __pyx_v_self=0x7f198bf7ecc0, __pyx_v_instance=<bytearray at remote 0x7f198bf7e070>) at src/buffers_formathandler.c:3395
#13 0x00007f198fa9778e in __pyx_f_17OpenGL_accelerate_21buffers_formathandler_17MemoryviewHandler_c_asArray (
    __pyx_v_self=0x7f198bf7ecc0, __pyx_v_instance=<bytearray at remote 0x7f198bf7e070>, 
    __pyx_v_typeCode=<IntConstant(name='GL_FLOAT') at remote 0x7f19907e6f80>) at src/buffers_formathandler.c:4039
#14 0x00007f19902b33ba in __pyx_pf_17OpenGL_accelerate_13arraydatatype_13ArrayDatatype_16asArray (__pyx_v_self=0x7f19907a50c0, 
    __pyx_v_value=<bytearray at remote 0x7f198bf7e070>, __pyx_v_typeCode=<IntConstant(name='GL_FLOAT') at remote 0x7f19907e6f80>)
    at src/arraydatatype.c:8908
#15 0x00007f19902b3146 in __pyx_pw_17OpenGL_accelerate_13arraydatatype_13ArrayDatatype_17asArray (
    __pyx_v_self=<OpenGL_accelerate.arraydatatype.ArrayDatatype at remote 0x7f19907a50c0>, __pyx_args=0x7ffcfb1e5d68, __pyx_nargs=1, 
    __pyx_kwds=0x0) at src/arraydatatype.c:8811
#16 0x00007f19902eeb77 in __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS (
    func=<_cython_3_0_4.cython_function_or_method at remote 0x7f19907d7510>, args=0x7ffcfb1e5d68, nargsf=2, kwnames=0x0)
    at src/arraydatatype.c:32445
#17 0x00007f19902e93a1 in __Pyx_PyObject_FastCallDict (func=<_cython_3_0_4.cython_function_or_method at remote 0x7f19907d7510>, 
--Type <RET> for more, q to quit, c to continue without paging--c
    args=0x7ffcfb1e5d60, _nargs=2, kwargs=0x0) at src/arraydatatype.c:29729
#18 0x00007f19902c5ab8 in __pyx_f_17OpenGL_accelerate_13arraydatatype_23AsArrayTypedSizeChecked_c_call (__pyx_v_self=0x7f198fb11b20, 
    __pyx_v_incoming=<bytearray at remote 0x7f198bf7e070>, 
    __pyx_v_function=<OpenGL_accelerate.wrapper.PyArgCalculator at remote 0x7f198bb01a00>, 
    __pyx_v_arguments=(<bytearray at remote 0x7f198bf7e070>,)) at src/arraydatatype.c:17915
#19 0x00007f198fe5ab1c in __pyx_f_17OpenGL_accelerate_7wrapper_22PyArgCalculatorElement_c_call (__pyx_v_self=0x7f198ba41490, 
    __pyx_v_args=(<bytearray at remote 0x7f198bf7e070>,)) at src/wrapper.c:9308
#20 0x00007f198fe5e19b in __pyx_f_17OpenGL_accelerate_7wrapper_15PyArgCalculator_c_call (__pyx_v_self=0x7f198bb01a00, 
    __pyx_v_args=(<bytearray at remote 0x7f198bf7e070>,)) at src/wrapper.c:10735
#21 0x00007f198fe65fca in __pyx_pf_17OpenGL_accelerate_7wrapper_7Wrapper_2__call__ (__pyx_v_self=0x7f198bff20c0, 
    __pyx_v_args=(<bytearray at remote 0x7f198bf7e070>,)) at src/wrapper.c:14723
#22 0x00007f198fe65e30 in __pyx_pw_17OpenGL_accelerate_7wrapper_7Wrapper_3__call__ (
    __pyx_v_self=<OpenGL_accelerate.wrapper.Wrapper at remote 0x7f198bff20c0>, __pyx_args=(<bytearray at remote 0x7f198bf7e070>,), 
    __pyx_kwds={}) at src/wrapper.c:14666
#23 0x00007f1990a3e2a7 in __Pyx_PyObject_Call (func=<OpenGL_accelerate.wrapper.Wrapper at remote 0x7f198bff20c0>, 
    arg=(<bytearray at remote 0x7f198bf7e070>,), kw={}) at src/latebind.c:7169
#24 0x00007f1990a35152 in __pyx_pf_17OpenGL_accelerate_8latebind_8LateBind_10__call__ (__pyx_v_self=0x7f198fb11ae0, 
    __pyx_v_args=(<bytearray at remote 0x7f198bf7e070>,), __pyx_v_named={}) at src/latebind.c:3336
#25 0x00007f1990a34e74 in __pyx_pw_17OpenGL_accelerate_8latebind_8LateBind_11__call__ (
    __pyx_v_self=<glColor3fv at remote 0x7f198fb11ae0>, __pyx_args=(<bytearray at remote 0x7f198bf7e070>,), __pyx_kwds=0x0)
    at src/latebind.c:3246
#26 0x00007f1995584cc9 in _PyObject_MakeTpCall (tstate=0x7f1995aa9218 <_PyRuntime+166328>, 
    callable=<glColor3fv at remote 0x7f198fb11ae0>, args=0x7f1995b19648, nargs=1, keywords=0x0) at Objects/call.c:214
#27 0x00007f1995584347 in _PyObject_VectorcallTstate (tstate=0x7f1995aa9218 <_PyRuntime+166328>, 
    callable=<glColor3fv at remote 0x7f198fb11ae0>, args=0x7f1995b19648, nargsf=9223372036854775809, kwnames=0x0)
    at ./Include/internal/pycore_call.h:90
#28 0x00007f19955850e2 in PyObject_Vectorcall (callable=<glColor3fv at remote 0x7f198fb11ae0>, args=0x7f1995b19648, 
    nargsf=9223372036854775809, kwnames=0x0) at Objects/call.c:299
#29 0x00007f19956d81a4 in _PyEval_EvalFrameDefault (tstate=0x7f1995aa9218 <_PyRuntime+166328>, frame=0x7f1995b195d0, throwflag=0)
    at Python/ceval.c:4760
#30 0x00007f19956bfa5a in _PyEval_EvalFrame (tstate=0x7f1995aa9218 <_PyRuntime+166328>, frame=0x7f1995b19498, throwflag=0)
    at ./Include/internal/pycore_ceval.h:73
#31 0x00007f19956e1162 in _PyEval_Vector (tstate=0x7f1995aa9218 <_PyRuntime+166328>, func=0x7f1993af39c0, locals=0x0, 
    args=0x7f198bbb9650, argcount=1, kwnames=('result',)) at Python/ceval.c:6425
#32 0x00007f1995585531 in _PyFunction_Vectorcall (func=<function at remote 0x7f1993af39c0>, stack=0x7f198bbb9650, nargsf=1, 
    kwnames=('result',)) at Objects/call.c:393
#33 0x00007f199558893f in _PyObject_VectorcallTstate (tstate=0x7f1995aa9218 <_PyRuntime+166328>, 
    callable=<function at remote 0x7f1993af39c0>, args=0x7f198bbb9650, nargsf=1, kwnames=('result',))
    at ./Include/internal/pycore_call.h:92
#34 0x00007f1995589004 in method_vectorcall (method=<method at remote 0x7f198bf7ec00>, args=0x7f198bbb9658, 
    nargsf=9223372036854775808, kwnames=('result',)) at Objects/classobject.c:59
#35 0x00007f1995584f0a in _PyVectorcall_Call (tstate=0x7f1995aa9218 <_PyRuntime+166328>, func=0x7f1995588ef7 <method_vectorcall>, 
    callable=<method at remote 0x7f198bf7ec00>, tuple=(), kwargs={'result': <TestCaseFunction at remote 0x7f198ef8b930>})
    at Objects/call.c:257
#36 0x00007f1995585233 in _PyObject_Call (tstate=0x7f1995aa9218 <_PyRuntime+166328>, callable=<method at remote 0x7f198bf7ec00>, 
    args=(), kwargs={'result': <TestCaseFunction at remote 0x7f198ef8b930>}) at Objects/call.c:328
#37 0x00007f199558532c in PyObject_Call (callable=<method at remote 0x7f198bf7ec00>, args=(), 
    kwargs={'result': <TestCaseFunction at remote 0x7f198ef8b930>}) at Objects/call.c:355
#38 0x00007f19956e4445 in do_call_core (tstate=0x7f1995aa9218 <_PyRuntime+166328>, func=<method at remote 0x7f198bf7ec00>, 
    callargs=(), kwdict={'result': <TestCaseFunction at remote 0x7f198ef8b930>}, use_tracing=0) at Python/ceval.c:7343
#39 0x00007f19956dc36e in _PyEval_EvalFrameDefault (tstate=0x7f1995aa9218 <_PyRuntime+166328>, frame=0x7f1995b19410, throwflag=0)
    at Python/ceval.c:5367
mgorny commented 10 months ago

Ping.