PYDEST=`pwd`

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

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

tar xvf Python-2.7.11.tgz
cd Python-2.7.11
LD_RUN_PATH=$PYDEST/pybug/lib:$LD_LIBRARY_PATH
export LD_RUN_PATH
OPT="-O0" ./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
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
