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

I'm getting a ton of errors about "Attempt to free non-existent shared string". These errors are coming from LinkExtor as they're all HTML tags.
Attempt to free non-existent shared string 'embed'. Attempt to free non-existent shared string 'xmp'. Attempt to free non-existent shared string 'object'. Attempt to free non-existent shared string 'tr'. Attempt to free non-existent shared string 'a'. Attempt to free non-existent shared string 'input'. Attempt to free non-existent shared string 'area'. Attempt to free non-existent shared string 'form'. Attempt to free non-existent shared string 'table'. Attempt to free non-existent shared string 'frame'. Attempt to free non-existent shared string 'img'. Attempt to free non-existent shared string 'body'. Attempt to free non-existent shared string 'isindex'. Attempt to free non-existent shared string 'bgsound'. Attempt to free non-existent shared string 'th'. Attempt to free non-existent shared string 'base'. ... Scalars leaked: -32 Bad signature in parser state object at 8359668. Unbalanced string table refcount: (1) for "tr" during global destructi +on. Unbalanced string table refcount: (1) for "isindex" during global dest +ruction. Unbalanced string table refcount: (1) for "applet" during global destr +uction. Unbalanced string table refcount: (1) for "del" during global destruct +ion. Unbalanced string table refcount: (1) for "_parser" during global dest +ruction. Unbalanced string table refcount: (1) for "input" during global destru +ction. Unbalanced string table refcount: (1) for "table" during global destru +ction. Unbalanced string table refcount: (1) for "link" during global destruc +tion. ... Scalars leaked: 37
Any ideas? Relevant code:
my @retlinks; if ($res->is_success) { $self->parser->parse($res->content); my @links = $self->parser->links; my $linkarray; foreach $linkarray (@links){ my @element = @$linkarray; my $elt_type = shift @element; while(@element){ my ($attr_name, $attr_val) = splice(@element, +0, 2); if($elt_type eq 'a' && $attr_name eq 'href'){ unshift(@retlinks, url($attr_val, $res +->base)->abs); } } } }
It all worked fine until I made that method threaded and then everthing went a little crazy. Advice appreciated. Thanks.

Replies are listed 'Best First'.
Re: LinkExtor Threading Leaks?
by zentara (Cardinal) on Jan 30, 2006 at 20:32 UTC
    It all worked fine until I made that method threaded

    You are trying to share an object across threads....don't do it. If you need to use threads, make sure the objects are thread-safe, or create new ones in each thread after the threads are created. Threads cannot be considered absolute independent processes, although they can run independently.


    I'm not really a human, but I play one on earth. flash japh
Re: LinkExtor Threading Leaks?
by BrowserUk (Patriarch) on Jan 30, 2006 at 20:29 UTC

    You don't show how you "made that method threaded"?

    I'd hazzard a guess that you are attempting to share one or more objects between threads via closures--and that doesn't work!

    You'll need to show the full code if you want a resolution.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.