CC: | stas [...] stason.org |
Subject: | PATCH: Env::C segmentation fault in getallenv() under Mac OSX 10.7 |
Date: | Thu, 21 Jun 2012 21:46:06 -0500 |
To: | bug-env-c [...] rt.cpan.org |
From: | Michael Schout <mschout [...] gkg.net> |
Hi Stas.
Not sure if you are aware of this or not, but Env::C::getallenv() blows
up on OS X 10.7 (Lion) with a segmentation fault. I built a debugging
perl and tracked it down to the first call to Perl_av_push() while
looping through *environ[]. Here is the backtrace under 5.16.0 (debug).
It blows up on all versions of perl I tested though (5.12, 5.14, and 5.16).
Show quoted text
> #0 Perl_av_push (av=0x890aa0, val=0x1008266e0) at av.c:562
> #1 0x000000010029ea90 in XS_Env__C_getallenv (cv=0x890aa0) at C.xs:143
> #2 0x00000001000cce1f in Perl_pp_entersub () at pp_hot.c:2778
> #3 0x0000000100099976 in Perl_runops_debug () at dump.c:2119
> #4 0x00000001000235a9 in S_run_body [inlined] () at /Users/mschout/perl5/perlbrew/build/perl-5.16.0/perl.c:2402
> #5 0x00000001000235a9 in perl_run (my_perl=0x100804c00) at perl.c:2320
> #6 0x0000000100000977 in main (argc=4, argv=0x7fff5fbff8a0, env=0x7fff5fbff8c8) at perlmain.c:120
My XS is a bit rusty, but the attached patch does fix the problem. I
tested this fix on Linux and OSX.
I also updated test.pl a bit to check that getallenv() does in fact
return the same thing as the contents of %ENV.
I tested this fix under Linux, using all of the following perls and it
passes the tests:
5.8.9, 5.10.1, 5.12.3, 5.16.0
I tested under OS X using 5.12.3 and 5.16.0.
If you have a different version of the fix you would like me to try and
you do not have access to a Mac, let me know.
Regards,
Michael Schout
Message body is not shown because sender requested not to inline it.