Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Program unexpectedly terminates

by ColonelPanic (Friar)
on Nov 19, 2012 at 08:31 UTC ( [id://1004481]=note: print w/replies, xml ) Need Help??


in reply to Program unexpectedly terminates

The code you have shown has a problem. You are assigning an array (1..100) as the value in a hash. You need an array reference for that (use brackets instead of parentheses). However, I doubt that is the real problem with your code--it was probably just a mistake when you created the simplified example.

Also, I tried your CORE::GLOBAL::exit override, and it didn't do anything--it only got worked if I explicitly called the exit() command, which your code does not.

I think your problem must be in the processing that you are not showing. It could be failing on the same one each time. Because you are processing in a random order, it would take varying amounts of time for that condition to be reached.

I suggest some good, old-fashioned debug print statements within your processing loop. Log the id of each record you are looking at, and record the success of each significant operation. That should help you to know where it fails.



When's the last time you used duct tape on a duct? --Larry Wall

Replies are listed 'Best First'.
Re^2: Program unexpectedly terminates
by Anonymous Monk on Nov 19, 2012 at 08:48 UTC
    The code you have shown has a problem. You are assigning an array (1..100) as the value in a hash. You need an array reference
    Yeah, yeah. That's obviously not working code and I was trimming down my real program to just show the basic structure.
    Also, I tried your CORE::GLOBAL::exit override, and it didn't do anything--it only got worked if I explicitly called the exit() command, which your code does not.
    I said in my OP I never directly call exit. But my unstated assumption is that one of the many CPAN modules I am using might be calling it.
    I think your problem must be in the processing that you are not showing. It could be failing on the same one each time. Because you are processing in a random order, it would take varying amounts of time for that condition to be reached.
    I'm intentionally not wrapping anything in eval, so if something in my code does fail, it should bomb out loudly. It never does.
    I suggest some good, old-fashioned debug print statements within your processing loop. Log the id of each record you are looking at, and record the success of each significant operation. That should help you to know where it fails.
    The print statement I have in the example already prints before the processing starts, so I see which record it stops at. It's never the same one. Plus, as I mentioned above, any error in my code would die loudly. But I'm not sure why the program can terminate with exit value of 0, yet the END block is never called. So my assumption is that one of the CPAN modules is at fault, but whatever is the cause, I was hoping there was some module that would perform the necessary overrides and tell me what's calling exit.

      Thanks for the additional information. I didn't understand that you were trying to trap explicit calls to exit(). That makes sense, then.

      Playing around more with the BEGIN block, I found that an exit() statement within another package was only overridden if the BEGIN block came before the package definition. Do you have this block before you include all of your modules?

      Also, would Test::Trap be helpful?



      When's the last time you used duct tape on a duct? --Larry Wall
        Yes, the code in the main package is exactly what I'm using- only the Crawler package is abreviated. Test::Trap is basically an eval and only traps &CORE::GLOBAL::exit, so I don't think it does anything else than what I've tried.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2025-03-28 08:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (71 votes). Check out past polls.

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.