Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Maybe you're right. I added a tons of logging just next to each lock occurrence to see at which point my app fails. I found that each time it was crashing near calling this function:
sub UnshareHash { my $reference = shift; lock $reference if is_shared($reference); given (ref $reference) { when ('HASH') { return { map UnshareHash($_), %{$reference} } } when ('ARRAY') { return [ map UnshareHash($_), @{$reference} ] } when ('REF') { return \UnshareHash($$reference) } default { return $reference } } }
I have a configuration object shared between threads which sometimes need to clone/unshare some part of it using the function above. I've changed the function to lock only the top-level structure:
sub UnshareHash { my $reference = shift; my $deep = shift; lock $reference if is_shared($reference) and not $deep; given (ref $reference) { when ('HASH') { return { map UnshareHash($_, 1), %{$reference} } } when ('ARRAY') { return [ map UnshareHash($_, 1), @{$reference} ] } when ('REF') { return \UnshareHash($$reference, 1) } default { return $reference } } }
For now it looks promising: my app runs for about 40 straight hours now. Before that crash happened after few hours at most, sometimes after few minutes. But that may be just a coincidence, i'll have to wait some more time.

But if it happens to be true (i.e. UnshareHash() is the culprit) then i assume that recursive locking is the problem? That would be a bug in threads::shared, wouldn't it?

In reply to Re^2: panic: COND_DESTROY(6) by menth0l
in thread panic: COND_DESTROY(6) by menth0l

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    [karlgoethebier]: moans
    [karlgoethebier]: ...because of sausage and luncheon meats...
    [karlgoethebier]: ... the ultimate coding experience for everyday people...
    [karlgoethebier]: me
    [marto]: what a mess
    [karlgoethebier]: perhaps i need a zerial?

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (7)
    As of 2017-12-14 10:31 GMT
    Find Nodes?
      Voting Booth?
      What programming language do you hate the most?

      Results (389 votes). Check out past polls.