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

Perl crossing arms silently: loop stoping without any error message

by Andre_br (Pilgrim)
on Feb 14, 2006 at 14:17 UTC ( [id://530123]=perlquestion: print w/replies, xml ) Need Help??

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

Hello my dear wise fellows

Iīve been trying to debug this for hours without success, so I desperately need thy wisdom now.

I have a script that analyses a tab delimited .txt file and imports the aproved lines into mysql. Everything rins smoothly with all my vendors, but with one of them the processing just freezes in the middle of the file, and without generating any error message.

I was able to detect at wich line it stops, but I just canīt figure out why this happens, as this line seems to be just ok.

Is there any diagnostics module wich I can use to make Perl yell about whatīs wrong, or at least at which line it is freezing?

The other day I solved a problem like this: Perl was freezing because a field being evaluated for > contained letters. But today I just canīt find anything!

Please help me fellow monks

Thanks a lot

André

  • Comment on Perl crossing arms silently: loop stoping without any error message

Replies are listed 'Best First'.
Re: Perl crossing arms silently: loop stoping without any error message
by holli (Abbot) on Feb 14, 2006 at 14:36 UTC
    Is there any diagnostics module wich I can use to make Perl yell about whatīs wrong, ...
    use warnings; use diagnostics;
    ... or at least at which line it is freezing?
    Put a
    print "$. $line";
    after you read your line. That prints the line and the line number.


    holli, /regexed monk/
Re: Perl crossing arms silently: loop stoping without any error message
by salva (Canon) on Feb 14, 2006 at 14:27 UTC
    run your script under the debugger: perldoc perldebug

    We would be able to give you better advice if you post some code and the data that causes your program to freeze.

Re: Perl crossing arms silently: loop stoping without any error message
by duff (Parson) on Feb 14, 2006 at 15:32 UTC

    Without looking at your code, I won't be able to tell you why it stops. You said that you found out at which line it stops. Step through your code's execution path for that line. (e.g. in the perl debugger as salva suggests) Or you can carefully analyze your code to see if you can divine an execution path that causes and infinite loop or perpetual blocking or whatever.

Re: Perl crossing arms silently: loop stoping without any error message
by graff (Chancellor) on Feb 15, 2006 at 00:43 UTC
    Based on the insufficient evidence you've given, I would raise the following issues:
    • Are you looking at the actual data file being used by the vendor in question, or is your diagnosis so far based on your own copy of that file?
    • How did you detect the input data line at which the program hangs? Maybe the problem is in the data line after this one, or maybe there's some other factor that is causing the last line you "see" to be different from the line that actually caused the problem.
    • When looking at that particular line (or any line in the data), how did you know that it "seems ok"? What if your script could not deal with some unexpected pattern of white-space characters? Are you looking at the file in such a way that you could spot that? (Certain control characters, especially "backspace" (0x08), can also cause problems that are hard to "see" if you don't look at the data the right way.)

    Maybe a global sanity-check for the input data would be worthwhile -- e.g. a separate perl script that reads in the same set of input data and simply tests the assumptions made by your database-loader script -- to settle those issues.

    Better yet, figure out what those tests should be, and include them in the database loader script itself, so it can reject bad data instead of choking on it. (But sometimes it can be easier to treat data validation as a separate, prior step.)

    Apart from that, it's just as important (or more so) to spot the line in your code where the script is hanging. If you start it with the debugger, you can just let it run until it looks to be in its "hung" state, then hit ^C to interrupt it. That will tell you which line was executing when the interrupt was handled, and you can start poking around, looking at values of variables to figure out how things are different from what you would expect.

Re: Perl crossing arms silently: loop stoping without any error message
by leocharre (Priest) on Feb 14, 2006 at 17:14 UTC

    make sure you got

    #!/usr/bin/perl -w

    pay attention to STDERR
    read the error-log
    maybe put some print STDERR "$your $junk $and $vars "; every hey and there, that might help you find the problem.

    how big *is* this file? how many lines?
    have you maybe found a line which is missing newlines somehow ?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://530123]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-19 05:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found