rsteinke has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to wrap a c++ library which uses STL (standard template library) iostreams (to wrap sockets, for log files, etc.) in an xsub. Everything builds fine, but sometimes it'll lock when I try to call this library from perl. I've tracked down the location of the locks in the c++ code, and they are always inside an STL function call involving iostreams. The funny thing is, whether the c++ code locks depends on the number and location of print calls in the perl code. It always locks in the same place for any given snippet of perl. This leads me to suspect that there's some problem with the interaction between io in c++ and perl. Any ideas where I should be looking? Are there arcane details about how perl handles io buffering I should know?

Replies are listed 'Best First'.
Re: xsub and c++ iostreams locking
by JayBonci (Curate) on Apr 19, 2002 at 20:34 UTC
    Can you narrow the code down to the smallest bit where it locks up, and then paste it in here? I don't see any STL caveats in the XSUB pods (perlxs or perlxstut), so if you can narrow it down to the smallest bit that hangs, perhaps it is something simple to work around. It's tough to eyeball a general problem like hang without the code, in any language.

        --jb
      When I tried to thin things down to a test case, I hit an internal error in g++ (both 2.95.4 and 3.0.4). I'll mail them and get back to you later.
Re: xsub and c++ iostreams locking
by rsteinke (Scribe) on Apr 19, 2002 at 18:56 UTC
    BTW, the system details are: perl 5.6.1, running on linux (debian testing)