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?

In reply to xsub and c++ iostreams locking by rsteinke

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.