Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Segfault on second (identical) call to a sub

by acid06 (Friar)
on Feb 06, 2006 at 04:14 UTC ( [id://528148]=note: print w/replies, xml ) Need Help??


in reply to Segfault on second (identical) call to a sub

I don't know if it helps at all, but while trying to trick it into working I managed to make matters even worse.

The code below produces the "free to wrong pool" error message even on the first call.

use strict; use GD; print "Perl:$]; $GD::VERSION \n"; for (1..10) { print "Iteration $_\n"; my $cap = x_generator( 100, 100 )->(); } sub x_generator { my ($x, $y) = @_; return sub { GD::Image->trueColor( 1 ); my $gd = GD::Image->new( $x, $y ); my $raw = $gd->gd; my $img = GD::Image->newFromGdData( $raw ) or die "$!, $^E"; return $img->jpeg; }; } __END__ Perl:5.008007; 2.30 Iteration 1 Free to wrong pool 222888 not 15c1b142 at testbug.pl line 9.


acid06
perl -e "print pack('h*', 16369646), scalar reverse $="

Replies are listed 'Best First'.
Re^2: Segfault on second (identical) call to a sub
by BrowserUk (Patriarch) on Feb 06, 2006 at 05:48 UTC

    Thanks, that did help. The extra level of sub call/return allowed me to see the stack frame just before and after the trap occurs (in 5.8.8). It's happening as perl cleans up it's stack after the nested call; in Perl_free_temps(). It shows (I think), that the problem is nothing to do with GD but rather with the perl executable itself:

    PID: 320 TID: 1716 - Stack Contents for 0x280EAF30 0x280EAF30: perl58.dll:VMem::Free + 0x0054 <Void> 0x280EF62F: perl58.dll:CPerlHost::Free + 0x0021 <Void> 0x280EBE12: perl58.dll:PerlMemFree + 0x0016 <Void> 0x280E4E37: perl58.dll:Perl_safesysfree + 0x002A <Void> 0x280AEE3B: perl58.dll:Perl_sv_clear + 0x06EE <Void> 0x280AF2B0: perl58.dll:Perl_sv_free + 0x013E <Void> 0x280024D5: perl58.dll:Perl_av_undef + 0x008D <Void> 0x280AED0E: perl58.dll:Perl_sv_clear + 0x05C1 <Void> 0x280AF2B0: perl58.dll:Perl_sv_free + 0x013E <Void> 0x280350D8: perl58.dll:Perl_pad_undef + 0x0227 <Void> 0x280EF62F: perl58.dll:CPerlHost::Free + 0x0021 <Void> 0x2802CD37: perl58.dll:Perl_cv_undef + 0x0138 <Void> 0x280AECEA: perl58.dll:Perl_sv_clear + 0x059D <Void> 0x280AF2B0: perl58.dll:Perl_sv_free + 0x013E <Void> 0x280A2CEA: perl58.dll:Perl_free_tmps + 0x0077 <Void> 0x28065C6F: perl58.dll:Perl_pp_nextstate + 0x005F <op *> 0x280A26CD: perl58.dll:Perl_runops_standard + 0x000F <Int> 0x2803A9C5: perl58.dll:S_run_body + 0x018F <Void> 0x2803A562: perl58.dll:perl_run + 0x008A <Int> 0x280EEC9F: perl58.dll:RunPerl + 0x00A1 <Int> 0x7C0068F7: __getmainargs + 0x00BD 0x00401012: perl.exe:main + 0x0012 <Int> 0x0040115A: perl.exe:mainCRTStartup + 0x0143 <Int> 0x77E814C7: GetCurrentDirectoryW + 0x0044

    In every other version I've traced, the stack is already corrupted by the time the trap occurs and so it was impossible to tell where I was in the code. I your version, the trap occurs much closer to the origin of the corruption and so the stack trace is still intact.

    If I could get a version of the trap that didn't call GD at all would be the best demonstration, but maybe the above stacktrace is convincing when combined with the same code running clean under 5.8.6--which I will now re-install.

    Thanks again for your help.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "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://528148]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-19 19:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found