delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/05/26/15:13:18

X-Spam-Check-By: sourceware.org
Message-ID: <44775331.4070809@ukf.net>
Date: Fri, 26 May 2006 20:12:49 +0100
From: Max Bowsher <maxb1 AT ukf DOT net>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050923 Thunderbird/1.0.7
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Cygwin G++ bug? - Python Extension module #including <iostream> dies before initialization
OpenPGP: id=C0F2C580
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

--------------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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019