This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: 2.7.10 glibc double free detected
Type: crash Stage: resolved
Components: Interpreter Core Versions: Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, wcolburnnrao, zach.ware
Priority: normal Keywords:

Created on 2015-10-22 21:08 by wcolburnnrao, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
debug.sh wcolburnnrao, 2015-12-30 22:39
Messages (6)
msg253354 - (view) Author: William D Colburn (wcolburnnrao) Date: 2015-10-22 21:08
Linking cython against the static libpython in a python install compiled with shared libraries causes a glibc error that a double free or corruption was found while importing site.  I don't think it is cython's fault.

Happens on RHEL6.6.
Linux anotheruvula 2.6.32-504.30.3.el6.x86_64 #1 SMP Thu Jul 9 15:20:47 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11)

I am attaching a shell script which demonstrates the problem.
msg253355 - (view) Author: William D Colburn (wcolburnnrao) Date: 2015-10-22 21:23
I don't see the shell script attached anywhere.

I'll just paste it here!

-----cut here-----
PYDEST=`pwd`

wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz
wget http://cython.org/release/Cython-0.23.4.tar.gz

rm -rf Python-2.7.10 Cython-0.23.4 ${PYDEST}/pybug

tar xvf Python-2.7.10.tgz
cd Python-2.7.10
LD_RUN_PATH=$PYDEST/pybug/lib:$LD_LIBRARY_PATH
export LD_RUN_PATH
./configure --prefix=$PYDEST/pybug --enable-shared
make -j 8
make install prefix=$PYDEST/pybug
cd ..
tar xvf Cython-0.23.4.tar.gz
cd Cython-0.23.4
$PYDEST/pybug/bin/python2.7 setup.py install
cd ..

cat > crash.py <<EOF
print 'hello world'
EOF

${PYDEST}/pybug//bin/cython --embed crash.py
gcc -g crash.c -I${PYDEST}/pybug/include/python2.7 ${PYDEST}/pybug/lib/python2.7/config/libpython2.7.a -lm -ldl -lutil -lpthread -o doublefree

##
## *** glibc detected *** ./doublefree: double free or corruption (out): 0x00007f57fb8c5030 ***
## crashes in PyInitialize() during "import site"
##
./doublefree
msg257242 - (view) Author: William D Colburn (wcolburnnrao) Date: 2015-12-30 22:39
I tried the test with Python 2.7.11, and it still crashes.
msg257254 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2015-12-31 11:02
I don't reproduce the crash, but I noticed that the binary imports and executes the system's /usr/lib/python2.7/site.py.

I think it's cython's fault (or maybe the way you use it): "cython --embed" is not really isolated from the rest of the system, so it can only be used with the system's Python.
msg257256 - (view) Author: William D Colburn (wcolburnnrao) Date: 2015-12-31 15:02
wcolburn@anotheruvula</home/anotheruvula/python/debug>$ strace doublefree 2>&1 | grep site.py
open("/home/anotheruvula/python/debug/pybug/lib/python2.7/site.py", O_RDONLY) = 3
open("/home/anotheruvula/python/debug/pybug/lib/python2.7/site.pyc", O_RDONLY) = 4
*** glibc detected *** doublefree: double free or corruption (out): 0x00007fa1eb491030 ***
======= Backtrace: =========

It's pulling in it's own site.py, not the system site.py when I do it.
msg367347 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2020-04-27 01:50
As Python 2.7 is now at end-of-life, I'm closing this issue.  If you can still reproduce the problem with a modern version of Python (3.6-3.8), please reopen it.
History
Date User Action Args
2022-04-11 14:58:23adminsetgithub: 69649
2020-04-27 01:50:48zach.waresetstatus: open -> closed

nosy: + zach.ware
messages: + msg367347

resolution: out of date
stage: resolved
2015-12-31 15:02:53wcolburnnraosetmessages: + msg257256
2015-12-31 11:02:19amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg257254
2015-12-30 22:39:07wcolburnnraosetfiles: + debug.sh

messages: + msg257242
2015-10-22 21:23:57wcolburnnraosetmessages: + msg253355
2015-10-22 21:08:22wcolburnnraocreate