Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: panic: attempt to copy freed scalar a7b9650 to ad20598

by mje (Curate)
on Dec 03, 2009 at 17:01 UTC ( [id://810876]=note: print w/replies, xml ) Need Help??


in reply to Re: panic: attempt to copy freed scalar a7b9650 to ad20598
in thread panic: attempt to copy freed scalar a7b9650 to ad20598

The sample was not quite right. The sub "dave" is a generic sub which calls a procedure with DBD::Oracle. The call to "dave" in the example does fail but what is missing from the example is that the catch also may call "dave" but with a different procedure name. This is closer:

use Try::Tiny; use Log::Log4perl qw(get_logger :levels); Log::Log4perl->init_and_watch('/etc/log4.conf', 60); my $log = get_logger('Q::S'); fred(); sub fred { my $x = try { # dave dies in the cases we get the panic dave('proc1', {}, 'arg1', 'arg2'); 0; } catch { my $ev = $_; if ($sometimes) { # sometimes goes this path and sometimes the + else eval { dave('proc2', {}, 'arg1', 'arg2'); 1; } or $log->warn("failed $@"); } else { $log->logwarn("test $_"); } 1; }; print "$x\n"; return if $x; # <---- this would be q.pl line 1895 } sub dave { # the following line would be DB.pm line 1380 my ($sth, $options, @args) = @_; }

Replies are listed 'Best First'.
Re^3: panic: attempt to copy freed scalar a7b9650 to ad20598
by runrig (Abbot) on Dec 03, 2009 at 17:39 UTC
    Re: trying to get a simple test case - After trying a simple die in dave(), try doing something simple in DBI, like selecting from a table that doesn't exist, with RaiseError set so that it dies. And with the variables scoped as closely as possible to that of your original program.
Re^3: panic: attempt to copy freed scalar a7b9650 to ad20598
by BrowserUk (Patriarch) on Dec 03, 2009 at 17:05 UTC

    What happens if you use "test $ev" instead?

      Not sure what you mean by that.

        Does using $ev in place of $_ in the last line of this snippet (in the real code) make any difference?

        my $ev = $_; #### You set $ev = $_ here if ($sometimes) { # sometimes goes this path and sometimes the + else eval { dave('proc2', {}, 'arg1', 'arg2'); 1; } or $log->warn("failed $@"); } else { $log->logwarn("test $_"); #### But then use $_ here

        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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-04-23 11:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found