Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^2: Program unexpectedly terminates

by Anonymous Monk
on Nov 19, 2012 at 08:48 UTC ( #1004485=note: print w/replies, xml ) Need Help??

in reply to Re: Program unexpectedly terminates
in thread 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
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.

Replies are listed 'Best First'.
Re^3: Program unexpectedly terminates
by ColonelPanic (Friar) on Nov 19, 2012 at 09:09 UTC

    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.

        Well, your code should be catching any normal exit case. You still won't be catching exit() within an eval block, but your END statement should happen nonetheless.

        I don't see any way forward other than basic debugging in order to narrow down where, exactly, this problem occurs.

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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2018-03-19 01:43 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (231 votes). Check out past polls.