Author vstinner
Recipients Paul Monson, petr.viktorin, serge-sans-paille, steve.dower, vstinner
Date 2019-08-28.16:12:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Ok, I'm able to reproduce the crash using:

git clone
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/ This test uses ctypes to call functions of the 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

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

$ wc -l

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

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

$ python3.8 
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.
Date User Action Args
2019-08-28 16:12:51vstinnersetrecipients: + vstinner, petr.viktorin, steve.dower, serge-sans-paille, Paul Monson
2019-08-28 16:12:51vstinnersetmessageid: <>
2019-08-28 16:12:51vstinnerlinkissue37140 messages
2019-08-28 16:12:51vstinnercreate