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


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.



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]