Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core dump in bleadperl from perl -e '$! = 9999; $a = $!;' #10178

Closed
p5pRT opened this issue Feb 15, 2010 · 9 comments
Closed

Core dump in bleadperl from perl -e '$! = 9999; $a = $!;' #10178

p5pRT opened this issue Feb 15, 2010 · 9 comments

Comments

@p5pRT
Copy link

p5pRT commented Feb 15, 2010

Migrated from rt.perl.org#72850 (status was 'resolved')

Searchable as RT72850$

@p5pRT
Copy link
Author

p5pRT commented Feb 15, 2010

From @timbunce

perl -e '$! = 9999; $a = $!;'
Bus error (core dumped)

#0 0x0012e008 in Perl_magic_get (my_perl=0x1000000, sv=0x10489f0, mg=0x847930) at mg.c​:1055
1055 SvRTRIM(sv);
(gdb) bt
#0 0x0012e008 in Perl_magic_get (my_perl=0x1000000, sv=0x10489f0, mg=0x847930) at mg.c​:1055
#1 0x00126d90 in Perl_mg_get (my_perl=0x1000000, sv=0x10489f0) at mg.c​:225
#2 0x00194f36 in Perl_sv_2nv (my_perl=0x1000000, sv=0x10489f0) at sv.c​:2463
#3 0x00166a66 in Perl_pp_add (my_perl=0x1000000) at pp_hot.c​:639
#4 0x00110ce1 in Perl_runops_debug (my_perl=0x1000000) at dump.c​:2049
#5 0x00038135 in S_run_body (my_perl=0x1000000, oldscope=1) at perl.c​:2308
#6 0x000371ce in perl_run (my_perl=0x1000000) at perl.c​:2233
#7 0x000021d5 in main (argc=3, argv=0xbfffeedc, env=0xbfffeeec) at perlmain.c​:117

(gdb) print *sv
$1 = {
  sv_any = 0x1024c74,
  sv_refcnt = 2,
  sv_flags = 17415,
  sv_u = {
  svu_pv = 0x0,
  svu_iv = 0,
  svu_uv = 0,
  svu_rv = 0x0,
  svu_array = 0x0,
  svu_hash = 0x0,
  svu_gp = 0x0
  }
}

Perl Info

Flags:
    category=core
    severity=critical

Site configuration information for perl 5.11.4:

Configured by timbo at Wed Feb 10 15:52:10 GMT 2010.

Summary of my perl5 (revision 5 version 11 subversion 4) configuration:
  Commit id: 2630fd9e8e31d2fd409e2e8ec16dc85d230a3eb3
  Platform:
    osname=darwin, osvers=10.2.0, archname=darwin-thread-multi-2level
    uname='darwin timac.local 10.2.0 darwin kernel version 10.2.0: tue nov 3 10:37:10 pst 2009; root:xnu-1486.2.11~1release_i386 i386 '
    config_args='-des -Doptimize=-g -DEBUGGING=both -Dusethreads -Dusemultiplicity -Dusedevel -Uversiononly -Dprefix=~/blead'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include',
    optimize='-g',
    cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include'
    ccversion='', gccversion='4.2.1 (Apple Inc. build 5646)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/usr/local/lib -L/opt/local/lib'
    libpth=/usr/local/lib /opt/local/lib /usr/lib
    libs=-lgdbm -ldbm -ldl -lm -lutil -lc
    perllibs=-ldl -lm -lutil -lc
    libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -L/opt/local/lib -fstack-protector'

Locally applied patches:
    


@INC for perl 5.11.4:
    /Users/timbo/blead/lib/perl5/site_perl/5.11.4/darwin-thread-multi-2level
    /Users/timbo/blead/lib/perl5/site_perl/5.11.4
    /Users/timbo/blead/lib/perl5/5.11.4/darwin-thread-multi-2level
    /Users/timbo/blead/lib/perl5/5.11.4
    /Users/timbo/blead/lib/perl5/site_perl/5.10.1
    /Users/timbo/blead/lib/perl5/site_perl/5.10.0
    /Users/timbo/blead/lib/perl5/site_perl
    .


Environment for perl 5.11.4:
    HOME=/Users/timbo
    LANG=en_IE.UTF-8
    LANGUAGE (unset)
    LC_ALL=en_IE.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/Users/timbo/blead/bin:/usr/local/perl5-blead-deb-thr/bin:/usr/local/openjdk6-b16-24_apr_2009-r1/bin:/opt/local/lib/postgresql83/bin:/Users/timbo/bin:/usr/local/perl58-i/bin:/usr/local/mysql/bin:/usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Feb 16, 2010

From @rgarcia

On 15 February 2010 15​:06, Tim Bunce <perlbug-followup@​perl.org> wrote​:

perl -e '$! = 9999; $a = $!;'
Bus error (core dumped)

I do not reproduce this ; what does strerror return for errno 9999 on
your system?
On my Linux it's​:
$ ./perl -le 'print $!=9999'
Unknown error 9999
and gdb with a breakpoint at mg.c​:1055 confirms this.

@p5pRT
Copy link
Author

p5pRT commented Feb 16, 2010

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Feb 16, 2010

From @nwc10

On Mon, Feb 15, 2010 at 06​:06​:50AM -0800, Tim Bunce wrote​:

perl -e '$! = 9999; $a = $!;'
Bus error (core dumped)

#0 0x0012e008 in Perl_magic_get (my_perl=0x1000000, sv=0x10489f0, mg=0x847930) at mg.c​:1055
1055 SvRTRIM(sv);
(gdb) bt
#0 0x0012e008 in Perl_magic_get (my_perl=0x1000000, sv=0x10489f0, mg=0x847930) at mg.c​:1055
#1 0x00126d90 in Perl_mg_get (my_perl=0x1000000, sv=0x10489f0) at mg.c​:225
#2 0x00194f36 in Perl_sv_2nv (my_perl=0x1000000, sv=0x10489f0) at sv.c​:2463
#3 0x00166a66 in Perl_pp_add (my_perl=0x1000000) at pp_hot.c​:639
#4 0x00110ce1 in Perl_runops_debug (my_perl=0x1000000) at dump.c​:2049
#5 0x00038135 in S_run_body (my_perl=0x1000000, oldscope=1) at perl.c​:2308
#6 0x000371ce in perl_run (my_perl=0x1000000) at perl.c​:2233
#7 0x000021d5 in main (argc=3, argv=0xbfffeedc, env=0xbfffeeec) at perlmain.c​:117

(gdb) print *sv
$1 = {
sv_any = 0x1024c74,
sv_refcnt = 2,
sv_flags = 17415,

0x4407

PVMG, POK, pPOK

sv_u = {
svu_pv = 0x0,

NULL. That's naughty. That SV is not well formed. I wonder, how did that come
to be?

Try the appended patch. Tested on Linux, but not OS X

Summary of my perl5 (revision 5 version 11 subversion 4) configuration​:
Commit id​: 2630fd9
Platform​:
osname=darwin, osvers=10.2.0, archname=darwin-thread-multi-2level

Nicholas Clark

Inline Patch
diff --git a/mg.c b/mg.c
index cc01547..06c899e 100644
--- a/mg.c
+++ b/mg.c
@@ -1048,7 +1048,8 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
 	else
 #endif
 	sv_setpv(sv, errno ? Strerror(errno) : "");
-	SvPOK_on(sv);	/* may have got removed during taint processing */
+	if (SvPOKp(sv))
+	    SvPOK_on(sv);    /* may have got removed during taint processing */
 	RESTORE_ERRNO;
 	}
 

@p5pRT
Copy link
Author

p5pRT commented Feb 16, 2010

From @smpeters

On Tue, Feb 16, 2010 at 3​:59 AM, Nicholas Clark <nick@​ccl4.org> wrote​:

On Mon, Feb 15, 2010 at 06​:06​:50AM -0800, Tim Bunce wrote​:

perl -e '$! = 9999; $a = $!;'
Bus error (core dumped)

#0  0x0012e008 in Perl_magic_get (my_perl=0x1000000, sv=0x10489f0, mg=0x847930) at mg.c​:1055
1055        SvRTRIM(sv);
(gdb) bt
#0  0x0012e008 in Perl_magic_get (my_perl=0x1000000, sv=0x10489f0, mg=0x847930) at mg.c​:1055
#1  0x00126d90 in Perl_mg_get (my_perl=0x1000000, sv=0x10489f0) at mg.c​:225
#2  0x00194f36 in Perl_sv_2nv (my_perl=0x1000000, sv=0x10489f0) at sv.c​:2463
#3  0x00166a66 in Perl_pp_add (my_perl=0x1000000) at pp_hot.c​:639
#4  0x00110ce1 in Perl_runops_debug (my_perl=0x1000000) at dump.c​:2049
#5  0x00038135 in S_run_body (my_perl=0x1000000, oldscope=1) at perl.c​:2308
#6  0x000371ce in perl_run (my_perl=0x1000000) at perl.c​:2233
#7  0x000021d5 in main (argc=3, argv=0xbfffeedc, env=0xbfffeeec) at perlmain.c​:117

(gdb) print *sv
$1 = {
  sv_any = 0x1024c74,
  sv_refcnt = 2,
  sv_flags = 17415,

0x4407

PVMG, POK, pPOK

  sv_u = {
    svu_pv = 0x0,

NULL. That's naughty. That SV is not well formed. I wonder, how did that come
to be?

Try the appended patch. Tested on Linux, but not OS X

Summary of my perl5 (revision 5 version 11 subversion 4) configuration​:
  Commit id​: 2630fd9
  Platform​:
    osname=darwin, osvers=10.2.0, archname=darwin-thread-multi-2level

Nicholas Clark

diff --git a/mg.c b/mg.c
index cc01547..06c899e 100644
--- a/mg.c
+++ b/mg.c
@​@​ -1048,7 +1048,8 @​@​ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
       else
 #endif
       sv_setpv(sv, errno ? Strerror(errno) : "");
-       SvPOK_on(sv);   /* may have got removed during taint processing */
+       if (SvPOKp(sv))
+           SvPOK_on(sv);    /* may have got removed during taint processing */
       RESTORE_ERRNO;
       }

That fixes it for me on OS X.

Steve

@p5pRT
Copy link
Author

p5pRT commented Feb 16, 2010

From @smpeters

On Tue, Feb 16, 2010 at 9​:12 AM, Steve Peters <steve@​fisharerojo.org> wrote​:

On Tue, Feb 16, 2010 at 3​:59 AM, Nicholas Clark <nick@​ccl4.org> wrote​:

On Mon, Feb 15, 2010 at 06​:06​:50AM -0800, Tim Bunce wrote​:

perl -e '$! = 9999; $a = $!;'
Bus error (core dumped)

#0  0x0012e008 in Perl_magic_get (my_perl=0x1000000, sv=0x10489f0, mg=0x847930) at mg.c​:1055
1055        SvRTRIM(sv);
(gdb) bt
#0  0x0012e008 in Perl_magic_get (my_perl=0x1000000, sv=0x10489f0, mg=0x847930) at mg.c​:1055
#1  0x00126d90 in Perl_mg_get (my_perl=0x1000000, sv=0x10489f0) at mg.c​:225
#2  0x00194f36 in Perl_sv_2nv (my_perl=0x1000000, sv=0x10489f0) at sv.c​:2463
#3  0x00166a66 in Perl_pp_add (my_perl=0x1000000) at pp_hot.c​:639
#4  0x00110ce1 in Perl_runops_debug (my_perl=0x1000000) at dump.c​:2049
#5  0x00038135 in S_run_body (my_perl=0x1000000, oldscope=1) at perl.c​:2308
#6  0x000371ce in perl_run (my_perl=0x1000000) at perl.c​:2233
#7  0x000021d5 in main (argc=3, argv=0xbfffeedc, env=0xbfffeeec) at perlmain.c​:117

(gdb) print *sv
$1 = {
  sv_any = 0x1024c74,
  sv_refcnt = 2,
  sv_flags = 17415,

0x4407

PVMG, POK, pPOK

  sv_u = {
    svu_pv = 0x0,

NULL. That's naughty. That SV is not well formed. I wonder, how did that come
to be?

Try the appended patch. Tested on Linux, but not OS X

Summary of my perl5 (revision 5 version 11 subversion 4) configuration​:
  Commit id​: 2630fd9
  Platform​:
    osname=darwin, osvers=10.2.0, archname=darwin-thread-multi-2level

Nicholas Clark

diff --git a/mg.c b/mg.c
index cc01547..06c899e 100644
--- a/mg.c
+++ b/mg.c
@​@​ -1048,7 +1048,8 @​@​ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
       else
 #endif
       sv_setpv(sv, errno ? Strerror(errno) : "");
-       SvPOK_on(sv);   /* may have got removed during taint processing */
+       if (SvPOKp(sv))
+           SvPOK_on(sv);    /* may have got removed during taint processing */
       RESTORE_ERRNO;
       }

That fixes it for me on OS X.

Steve

Here's a test case for the fix as well.

Steve

--- a/t/op/magic.t
+++ b/t/op/magic.t
@​@​ -12,7 +12,7 @​@​ BEGIN {
use warnings;
use Config;

-plan (tests => 79);
+plan (tests => 80);

$Is_MSWin32 = $^O eq 'MSWin32';
$Is_NetWare = $^O eq 'NetWare';
@​@​ -491,3 +491,9 @​@​ foreach my $sig (qw(__DIE__ _BOGUS_HOOK KILL THIRSTY)) {
  is $SIG{$sig}, undef, "$sig is not present";
  is delete $SIG{$sig}, undef, "delete of $sig returns undef";
}
+
+{
+ $! = 9999;
+ is int $!, 9999, q{[perl #72850] Core dump in bleadperl from perl
-e '$! = 9999; $a = $!;'};
+
+}

@p5pRT
Copy link
Author

p5pRT commented Feb 16, 2010

From @nwc10

On Tue, Feb 16, 2010 at 09​:25​:21AM -0600, Steve Peters wrote​:

On Tue, Feb 16, 2010 at 9​:12 AM, Steve Peters <steve@​fisharerojo.org> wrote​:

On Tue, Feb 16, 2010 at 3​:59 AM, Nicholas Clark <nick@​ccl4.org> wrote​:

Try the appended patch. Tested on Linux, but not OS X

Summary of my perl5 (revision 5 version 11 subversion 4) configuration​:
  Commit id​: 2630fd9
  Platform​:
    osname=darwin, osvers=10.2.0, archname=darwin-thread-multi-2level

Nicholas Clark

diff --git a/mg.c b/mg.c
index cc01547..06c899e 100644
--- a/mg.c
+++ b/mg.c
@​@​ -1048,7 +1048,8 @​@​ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
       else
 #endif
       sv_setpv(sv, errno ? Strerror(errno) : "");
-       SvPOK_on(sv);   /* may have got removed during taint processing */
+       if (SvPOKp(sv))
+           SvPOK_on(sv);    /* may have got removed during taint processing */
       RESTORE_ERRNO;
       }

That fixes it for me on OS X.

Steve

Here's a test case for the fix as well.

Thanks, applied as part of be1cf43

Nicholas Clark

@p5pRT
Copy link
Author

p5pRT commented Feb 16, 2010

From @nwc10

Fixed in be1cf43

@p5pRT
Copy link
Author

p5pRT commented Feb 16, 2010

@nwc10 - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant