STINNER Victor <vstin...@python.org> added the comment:

Ok, I'm able to reproduce the crash using:

git clone https://github.com/llvm/llvm-project.git
cd llvm-project
mkdir _build
cd _build
cmake3 ../llvm -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" 
-DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release 
-DCMAKE_INSTALL_PREFIX=$PWD/install 
-DPYTHON_EXECUTABLE=$HOME/sources/cpython/_build/install/bin/python3
make -j4
make check-clang-python

The crash occurs in the test_access_specifiers() method defined in 
tests/cindex/test_access_specifiers.py. This test uses ctypes to call functions 
of the libclang.so dynamic library.

I reduced the test case from 4350 lines of Python code to 131 lines of Python 
which only depends on the standard library and libclang.so.

$ cd llvm-project/clang/bindings/python
$ wc -l tests/cindex/test_access_specifiers.py tests/cindex/util.py 
clang/cindex.py 
    41 tests/cindex/test_access_specifiers.py
    90 tests/cindex/util.py
  4219 clang/cindex.py
  4350 total

$ wc -l bug.py
131 bug.py

See attached bug.py script. Python 3.7 is fine, whereas Python 3.8 does crash:

$ python3.7 bug.py 
spelling
spelling = None
_CXString del: obj id=7f0904a6dcb0
spelling = None ---


$ python3.8 bug.py 
spelling
spelling = None
_CXString del: obj id=7f4fa6180c40
_CXString del: obj id=7f4fa6180ac0
free(): double free detected in tcache 2
Aborted (core dumped)


Notice that _CXString.__del__() is only called once in Python 3.7, but called 
twice in Python 3.8.

----------
Added file: https://bugs.python.org/file48565/bug.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37140>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to