Bug 1439091

Summary: "Attempt to free invalid pointer" on fedora:25 using tcmalloc compiled python module and spaCy library
Product: [Fedora] Fedora Reporter: fiete.gruenter
Component: gperftoolsAssignee: Tom "spot" Callaway <tcallawa>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 25CC: tcallawa
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-12-12 10:26:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description fiete.gruenter 2017-04-05 08:32:11 UTC
Description of problem:

When running spaCy (a python library for NLP) after importing a compiled python module linked against tcmalloc on fedora:25 I get an "Attempt to free invalid pointer".


Version-Release number of selected component (if applicable): gperftools: 2.5, fedora:25


How reproducible: always


Steps to Reproduce:

~~~
docker run -ti fedora:25 bash
dnf install python3-devel gperftools-devel gcc-c++ redhat-rpm-config
pip3 install spacy==1.7.3 cython==0.25.2
python3 -m spacy download en
cd /tmp
touch testclass.pyx
~~~

Create `setup.py` with the following content:

~~~
from setuptools import setup
from setuptools.extension import Extension


setup(
    name='testpackage',
    version='0.1',
    ext_modules=[
        Extension('testclass',
                  ['testclass.pyx'],
                  language='c++',
                  libraries=['tcmalloc_minimal']),
    ]
)
~~~

Run:

~~~
python3 setup.py install
python3 -c "import testclass; import spacy; spacy.load('en')('Test')"
~~~


## `gdb` dump
~~~
#0  0x00007ffff6c4992f in raise () from /lib64/libc.so.6
#1  0x00007ffff6c4b52a in abort () from /lib64/libc.so.6
#2  0x00007ffff67d6509 in tcmalloc::Log(tcmalloc::LogMode, char const*, int, tcmalloc::LogItem, tcmalloc::LogItem, tcmalloc::LogItem, tcmalloc::LogItem) () from /lib64/libtcmalloc_minimal.so.4
#3  0x00007ffff67d2319 in (anonymous namespace)::InvalidFree(void*) () from /lib64/libtcmalloc_minimal.so.4
#4  0x00007ffff67e0c2d in tc_free () from /lib64/libtcmalloc_minimal.so.4
#5  0x00007fffd56f8909 in __pyx_t_5spacy_6syntax_6_state_StateC::~__pyx_t_5spacy_6syntax_6_state_StateC (this=0x55555e19dff0, __in_chrg=<optimized out>) at spacy/syntax/parser.cpp:18569
#6  __pyx_f_5spacy_6syntax_6parser_6Parser_parseC (__pyx_v_self=0x7fffe6139d68, __pyx_v_tokens=0x5555615361c8, __pyx_v_length=1, __pyx_v_nr_feat=<optimized out>) at spacy/syntax/parser.cpp:9247
#7  0x00007fffd56e8b3b in __pyx_pf_5spacy_6syntax_6parser_6Parser_6__call__ (__pyx_v_tokens=<optimized out>, __pyx_v_self=0x7fffe6139d68) at spacy/syntax/parser.cpp:7654
#8  __pyx_pw_5spacy_6syntax_6parser_6Parser_7__call__ (__pyx_v_self=0x7fffe6139d68, __pyx_args=<optimized out>, __pyx_kwds=<optimized out>) at spacy/syntax/parser.cpp:7593
#9  0x00007ffff796e167 in PyObject_Call () from /lib64/libpython3.5m.so.1.0
#10 0x00007ffff7a2a5ea in PyEval_EvalFrameEx () from /lib64/libpython3.5m.so.1.0
#11 0x00007ffff7a2f9b3 in _PyEval_EvalCodeWithName () from /lib64/libpython3.5m.so.1.0
#12 0x00007ffff7a2fa93 in PyEval_EvalCodeEx () from /lib64/libpython3.5m.so.1.0
#13 0x00007ffff7999278 in function_call () from /lib64/libpython3.5m.so.1.0
#14 0x00007ffff796e167 in PyObject_Call () from /lib64/libpython3.5m.so.1.0
#15 0x00007ffff7984d04 in method_call () from /lib64/libpython3.5m.so.1.0
#16 0x00007ffff796e167 in PyObject_Call () from /lib64/libpython3.5m.so.1.0
#17 0x00007ffff79cd460 in slot_tp_call () from /lib64/libpython3.5m.so.1.0
#18 0x00007ffff796e167 in PyObject_Call () from /lib64/libpython3.5m.so.1.0
#19 0x00007ffff7a2a5ea in PyEval_EvalFrameEx () from /lib64/libpython3.5m.so.1.0
#20 0x00007ffff7a2f9b3 in _PyEval_EvalCodeWithName () from /lib64/libpython3.5m.so.1.0
#21 0x00007ffff7a2fa93 in PyEval_EvalCodeEx () from /lib64/libpython3.5m.so.1.0
#22 0x00007ffff7a2fabb in PyEval_EvalCode () from /lib64/libpython3.5m.so.1.0
#23 0x00007ffff7a4ed44 in run_mod () from /lib64/libpython3.5m.so.1.0
#24 0x00007ffff7a506e5 in PyRun_StringFlags () from /lib64/libpython3.5m.so.1.0
#25 0x00007ffff7a5074b in PyRun_SimpleStringFlags () from /lib64/libpython3.5m.so.1.0
#26 0x00007ffff7a67957 in Py_Main () from /lib64/libpython3.5m.so.1.0
#27 0x0000555555554b60 in main ()
~~~


Ways to avoid the problem aka "why I'm reporting this here":

* Import `spacy` before `testclass`, i.e. python3 -c "import spacy; import testclass; spacy.load('en')('Test')"
* Set `LD_PRELOAD="/usr/lib64/libtcmalloc_minimal.so.4"` before starting the python interpreter
* Use ubuntu:16.10 instead of fedora:25

Comment 1 Fedora End Of Life 2017-11-16 18:32:23 UTC
This message is a reminder that Fedora 25 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 25. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '25'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 25 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 2 Fedora End Of Life 2017-12-12 10:26:13 UTC
Fedora 25 changed to end-of-life (EOL) status on 2017-12-12. Fedora 25 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.