Cygwin G++ bug? - Python Extension module #including <iostream> dies before initialization
Max Bowsher
maxb1@ukf.net
Fri May 26 19:13:00 GMT 2006
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=`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="tinytestcase",
version="1.0",
description="",
author="",
author_email="",
ext_modules=[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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 188 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin/attachments/20060526/b72d6879/attachment.sig>
More information about the Cygwin
mailing list