This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Cygwin G++ bug? - Python Extension module #including <iostream> dies before initialization


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:
set -e
python clean -a build
PYTHONPATH=`echo build/lib.*` python -c 'import tinytestcase; print
"Test OK"'
echo "---"
#!/usr/bin/env python

from distutils.core import setup, Extension

      ext_modules=[Extension("tinytestcase", ["tinytestcase.cpp"])]

#include <iostream>

Run Python ought to complain like so:

   ImportError: dynamic module does not define init function

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.


Attachment: signature.asc
Description: OpenPGP digital signature

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]