Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I've managed to reproduce this on a single cpu windows machine with AS5.8.8 (using ping instead of smtp) and it appears to be a bug in the handling of backticks within threads.

The symptoms I am seeing are that one thread hangs, never returning from the backticks, even though I can see that all instances of the executable (ping.exe) have terminated. Using this simplified version of your thread code with added trace:

sub SNMPthread { my $thread = shift; while ( my $left = $q->pending ) { warn "$thread: $left"; my $ip = $q->dequeue; warn "$thread: $left, $ip"; my $return = `ping $ip`; warn sprintf "$thread: $left got %d bytes of output\n", length + $return; my @ele = split ' ', $return; warn "$thread: $left, $ip, $ele[ -4 ], $ele[ -1 ]"; } warn "thread $thread finished\n"; }

The trace for the hanging thread is:

8: 94 at C:\test\662828.pl line 30. 8: 94, 212.58.227.137 at C:\test\662828.pl line 32. 8: 94 got 471 bytes of output 8: 94, 212.58.227.137, 204ms,, 192ms at C:\test\662828.pl line 36. 8: 88 at C:\test\662828.pl line 30. 8: 88, 30.207.168.74 at C:\test\662828.pl line 32. 8: 88 got 228 bytes of output 8: 88, 30.207.168.74, =, loss), at C:\test\662828.pl line 36. 8: 78 at C:\test\662828.pl line 30. 8: 78, 202.229.106.211 at C:\test\662828.pl line 32.

As you can see, each IP is producing 4 lines of trace. Two before the backticks and two after. On it's third attempt, the backticks hang. However, the spawned ping instance goes away, so it's internal to Perl rather than the executable where the hang is occuring. The latter also suggested by the fact I can reproduce it using a different executable under a different OS.

I've tried substituting a piped open for backticks and varied the number of threads with the same result. Always one thread only that hangs. So it appears to be an internal problem that is the culprit.

However, I do have a fix for you. Upgrade to 5.10.0. The same code completes successfully using it, which also tends to indicate that it's a Perl problem, that's been fixed already.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: threads hang by BrowserUk
in thread threads hang by Ryszard

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-25 07:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found