Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^2: panic: COND_DESTROY(6)

by menth0l (Monk)
on Feb 01, 2012 at 09:02 UTC ( #951153=note: print w/replies, xml ) Need Help??

in reply to Re: panic: COND_DESTROY(6)
in thread panic: COND_DESTROY(6)

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?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://951153]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2017-04-26 22:26 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (491 votes). Check out past polls.