Valgrind warnings on Python 3.11, but not with Python 3.10 or Python 3.9

On Linux i’m seeing Valgrind warnings inside the Python interpreter with Python-3.11 but not with Python-3.10 or Python-3.9.

This is when running pytest tests on the Python extension PyMuPDF (which gives an extended Python API onto the MuPDF C PDF library), in a Github Action on Ubuntu-22.04.2.

The Valgrind warnings appear to happen both before and after pytest starts running tests.

I am setting PYTHONMALLOC=malloc when running pytest.

Here’s a typical warning:

Conditional jump or move depends on uninitialised value(s)
   at 0x4A63423: maybe_small_long (/home/runner/work/_temp/SourceCode/Objects/longobject.c:71)
   by 0x4A63423: _PyLong_FromByteArray (/home/runner/work/_temp/SourceCode/Objects/longobject.c:922)
   by 0x4A63423: int_from_bytes_impl (/home/runner/work/_temp/SourceCode/Objects/longobject.c:5946)
   by 0x4A63423: int_from_bytes (/home/runner/work/_temp/SourceCode/Objects/clinic/longobject.c.h:389)
   by 0x4A78AE9: cfunction_vectorcall_FASTCALL_KEYWORDS (/home/runner/work/_temp/SourceCode/Objects/methodobject.c:443)
   by 0x4A510FB: _PyObject_VectorcallTstate (/home/runner/work/_temp/SourceCode/./Include/internal/pycore_call.h:92)
   by 0x4A510FB: PyObject_Vectorcall (/home/runner/work/_temp/SourceCode/Objects/call.c:299)
   by 0x4AAEFD0: _PyEval_EvalFrameDefault (/home/runner/work/_temp/SourceCode/Python/ceval.c:4772)
   by 0x4AADC3E: _PyEval_EvalFrame (/home/runner/work/_temp/SourceCode/./Include/internal/pycore_ceval.h:73)
   by 0x4AADC3E: _PyEval_Vector (/home/runner/work/_temp/SourceCode/Python/ceval.c:6435)
   by 0x4A51297: _PyObject_VectorcallTstate (/home/runner/work/_temp/SourceCode/./Include/internal/pycore_call.h:92)
   by 0x4A51297: object_vacall (/home/runner/work/_temp/SourceCode/Objects/call.c:819)
   by 0x4A52485: PyObject_CallMethodObjArgs (/home/runner/work/_temp/SourceCode/Objects/call.c:879)
   by 0x4AC8D80: import_find_and_load (/home/runner/work/_temp/SourceCode/Python/import.c:1736)
   by 0x4AC8D80: PyImport_ImportModuleLevelObject (/home/runner/work/_temp/SourceCode/Python/import.c:1835)
   by 0x4AAC3A2: builtin___import___impl (/home/runner/work/_temp/SourceCode/Python/bltinmodule.c:277)
   by 0x4AAC3A2: builtin___import__ (/home/runner/work/_temp/SourceCode/Python/clinic/bltinmodule.c.h:78)
   by 0x4A78AE9: cfunction_vectorcall_FASTCALL_KEYWORDS (/home/runner/work/_temp/SourceCode/Objects/methodobject.c:443)
   by 0x4A50241: _PyObject_VectorcallTstate (/home/runner/work/_temp/SourceCode/./Include/internal/pycore_call.h:92)
   by 0x4A50241: _PyObject_CallFunctionVa (/home/runner/work/_temp/SourceCode/Objects/call.c:536)
   by 0x4A50241: PyObject_CallFunction (/home/runner/work/_temp/SourceCode/Objects/call.c:558)
   by 0x4AC917F: PyImport_Import (/home/runner/work/_temp/SourceCode/Python/import.c:2024)

Is this a known problem with Python-3.11? I haven’t found anything about Valgrind in the 3.11 changelog.

Any advice would be gratefully received.

Thanks,

- Julian

I think this issue is already being discussed in cpython3:fuzz_builtin_unicode: Use-of-uninitialized-value in maybe_small_long · Issue #102509 · python/cpython · GitHub

1 Like