Mail Archives: cygwin/2006/05/26/15:13:18
--------------enig0C3E3790E8225FDCFA51EB2D
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hi,
I compiled a C++ Python Extension, and found that it caused the Python
interpreter process to silently die (with a *zero* exitcode!) when it
attempted to load the extension module.
I traced the problem to the line:
static ios_base::Init __ioinit;
in <iostream>.
It seems that when the module is dlopen()-ed, something involved in this
static initializer terminates the process.
At this point, the problem goes a bit beyond my ability to debug. I'm
hoping someone can step in and provide insight here.
Testcase to reproduce the above:
testit.sh
[[[
#!/bin/sh
set -e
python setup.py clean -a build
PYTHONPATH=3D`echo build/lib.*` python -c 'import tinytestcase; print
"Test OK"'
echo "---"
]]]
setup.py
[[[
#!/usr/bin/env python
from distutils.core import setup, Extension
setup(name=3D"tinytestcase",
version=3D"1.0",
description=3D"",
author=3D"",
author_email=3D"",
ext_modules=3D[Extension("tinytestcase", ["tinytestcase.cpp"])]
)
]]]
tinytestcase.cpp
[[[
#include <iostream>
]]]
Run testit.sh. Python ought to complain like so:
ImportError: dynamic module does not define init function
(inittinytestcase)
but instead, no output from Python is visible at all - it died.
Now, copy /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/iostream to
./local_iostream, and change tinytestcase.cpp to #include
"local_iostream" instead.
Verify that the bug still reproduces.
Now, comment out the static initializer mentioned earlier - observe that
the bug has disappeared.
Max.
--------------enig0C3E3790E8225FDCFA51EB2D
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
iD8DBQFEd1M2fFNSmcDyxYARAhOMAJ0SPmN8FHpsGcYiUaOgR6F2rYMA6wCeLeQQ
YM3i/jjxyGiGIsoS4ZY5jko=
=tJqI
-----END PGP SIGNATURE-----
--------------enig0C3E3790E8225FDCFA51EB2D--
- Raw text -