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?