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

dtrace sub-entry probe against lexical sub segfaults #13014

Open
p5pRT opened this issue Jun 4, 2013 · 9 comments
Open

dtrace sub-entry probe against lexical sub segfaults #13014

p5pRT opened this issue Jun 4, 2013 · 9 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 4, 2013

Migrated from rt.perl.org#118305 (status was 'open')

Searchable as RT118305$

@p5pRT
Copy link
Author

p5pRT commented Jun 4, 2013

From @rjbs

Created by @rjbs

I have compiled blead (929c6ec) -Dusedtrace and run​:

  ./perl -Ilib -E 'use feature "lexical_subs"; my sub x { say 1 }
  while (1) { sleep 1; x; }'

This starts emitting a slow steady stream of ones. It is just fine.

After a while, I run​:

  sudo dtrace -Zn 'perl​::sub-entry /execname == "perl"/ { }'
  dtrace​: description 'perl​::sub-entry ' matched 4 probes

The original perl program segfaults within a second.

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl 5.19.1:

Configured by rjbs at Tue Jun  4 13:37:13 CDT 2013.

Summary of my perl5 (revision 5 version 19 subversion 1) configuration:
  Commit id: 929c6ecf94db1e29600848f3d1acc64c825d9fc7
  Platform:
    osname=darwin, osvers=12.3.0, archname=darwin-2level
    uname='darwin walrus.local 12.3.0 darwin kernel version 12.3.0: sun jan 6 22:37:10 pst 2013; root:xnu-2050.22.13~1release_x86_64 x86_64 '
    config_args='-des -Dusedevel -Dusedtrace'
    hint=previous, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include',
    optimize='-O3',
    cppflags='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include -fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include'
    ccversion='', gccversion='4.2.1 Compatible Apple Clang 4.0 ((tags/Apple/clang-421.0.57))', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, 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=, 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.19.1:
    lib
    /Users/rjbs/.perlbrew/libs/19.0@std/lib/perl5/darwin-2level
    /Users/rjbs/.perlbrew/libs/19.0@std/lib/perl5
    /usr/local/lib/perl5/site_perl/5.19.1/darwin-2level
    /usr/local/lib/perl5/site_perl/5.19.1
    /usr/local/lib/perl5/5.19.1/darwin-2level
    /usr/local/lib/perl5/5.19.1
    .


Environment for perl 5.19.1:
    DYLD_LIBRARY_PATH (unset)
    HOME=/Users/rjbs
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/Users/rjbs/.perlbrew/libs/19.0@std/bin:/Users/rjbs/perl5/perlbrew/bin:/Users/rjbs/perl5/perlbrew/perls/19.0/bin:/Users/rjbs/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/Users/rjbs/code/hla
    PERL5LIB=/Users/rjbs/.perlbrew/libs/19.0@std/lib/perl5
    PERLBREW_BASHRC_VERSION=0.63
    PERLBREW_HOME=/Users/rjbs/.perlbrew
    PERLBREW_LIB=std
    PERLBREW_MANPATH=/Users/rjbs/.perlbrew/libs/19.0@std/man:/Users/rjbs/perl5/perlbrew/perls/19.0/man
    PERLBREW_PATH=/Users/rjbs/.perlbrew/libs/19.0@std/bin:/Users/rjbs/perl5/perlbrew/bin:/Users/rjbs/perl5/perlbrew/perls/19.0/bin
    PERLBREW_PERL=19.0
    PERLBREW_ROOT=/Users/rjbs/perl5/perlbrew
    PERLBREW_VERSION=0.63
    PERLDOC=-n/opt/local/bin/groff
    PERL_AUTOINSTALL=--skipdeps
    PERL_BADLANG (unset)
    PERL_LOCAL_LIB_ROOT=/Users/rjbs/.perlbrew/libs/19.0@std
    PERL_MAILERS=sendmail:/Users/rjbs/bin/sendmail
    PERL_MB_OPT=--install_base /Users/rjbs/.perlbrew/libs/19.0@std
    PERL_MM_OPT=INSTALL_BASE=/Users/rjbs/.perlbrew/libs/19.0@std
    SHELL=/opt/local/bin/zsh

@p5pRT
Copy link
Author

p5pRT commented Jun 5, 2013

From @cpansprout

On Tue Jun 04 11​:48​:38 2013, rjbs wrote​:

This is a bug report for perl from rjbs@​cpan.org,
generated with the help of perlbug 1.39 running under perl 5.19.1.

-----------------------------------------------------------------
[Please describe your issue here]

I have compiled blead (929c6ec) -Dusedtrace and run​:

./perl -Ilib -E 'use feature "lexical_subs"; my sub x { say 1 }
while (1) { sleep 1; x; }'

This starts emitting a slow steady stream of ones. It is just fine.

After a while, I run​:

sudo dtrace -Zn 'perl​::sub-entry /execname == "perl"/ { }'
dtrace​: description 'perl​::sub-entry ' matched 4 probes

The original perl program segfaults within a second.

The attached patch seems to do the trick. I don’t know dtrace well
enough to write a test for it. It also happens that t/run/dtrace.t is
failing for me right now (at 35e3dd0)​:

$ sudo ./perl t/harness run/dtrace.t
run/dtrace.t .. 2/9 dtrace​: error on enabled probe ID 4 (ID 26502​:
perl21968​:perl​:S_parse_body​:phase-change)​: invalid address (0x106e90cc3)
in action #1 at DIF offset 24
run/dtrace.t .. 3/9 dtrace​: error on enabled probe ID 4 (ID 26502​:
perl21970​:perl​:S_parse_body​:phase-change)​: invalid address (0x10c00bcc3)
in action #1 at DIF offset 24
run/dtrace.t .. 4/9 dtrace​: error on enabled probe ID 17 (ID 26502​:
perl21972​:perl​:S_parse_body​:phase-change)​: invalid address (0x10134dccd)
in predicate at DIF offset 24
dtrace​: error on enabled probe ID 29 (ID 26502​:
perl21972​:perl​:S_parse_body​:phase-change)​: invalid address (0x10134dccd)
in predicate at DIF offset 24
dtrace​: error on enabled probe ID 43 (ID 2559​:
perl21956​:perl​:Perl_pp_entersub​:sub-entry)​: invalid address
(0x10134dccd) in predicate at DIF offset 52
dtrace​: error on enabled probe ID 43 (ID 2559​:
perl21956​:perl​:Perl_pp_entersub​:sub-entry)​: invalid address
(0x10134dccd) in predicate at DIF offset 52
run/dtrace.t .. 5/9 dtrace​: error on enabled probe ID 2 (ID 26500​:
perl21974​:perl​:Perl_runops_debug​:op-entry)​: invalid address
(0x10f8c91ba) in action #1 at DIF offset 24
dtrace​: error on enabled probe ID 2 (ID 26500​:
perl21974​:perl​:Perl_runops_debug​:op-entry)​: invalid address
(0x10f8c91a0) in action #1 at DIF offset 24
dtrace​: error on enabled probe ID 2 (ID 26500​:
perl21974​:perl​:Perl_runops_debug​:op-entry)​: invalid address
(0x10f8c91a0) in action #1 at DIF offset 24
dtrace​: error on enabled probe ID 2 (ID 26500​:
perl21974​:perl​:Perl_runops_debug​:op-entry)​: invalid address
(0x10f8c91a0) in action #1 at DIF offset 24
dtrace​: error on enabled probe ID 2 (ID 26500​:
perl21974​:perl​:Perl_runops_debug​:op-entry)​: invalid address
(0x10f8c91c0) in action #1 at DIF offset 24
run/dtrace.t .. 8/9 # Failed test 9 - loading-file, loaded-file probes
at run/dtrace.t line 191
# got 'loaded-file <warnings.pm>
# loading-file <Carp.pm>
# loaded-file <Carp.pm>
# loading-file <Exporter.pm>
# loaded-file <Exporter.pm>
# loading-file <strict.pm>
# loaded-file <strict.pm>
# loading-file <HTTP/Tiny.pm>
# loading-file <warnings.pm>
# loading-file <bytes.pm>
# loaded-file <bytes.pm>
# loading-file <Errno.pm>
# loading-file <Config.pm>
# loading-file <vars.pm>
# loading-file <warnings/register.pm>
# loaded-file <warnings/register.pm>
# loaded-file <vars.pm>
# loaded-file <Config.pm>
# loaded-file <Errno.pm>
# loading-file <IO/Socket.pm>
# loading-file <IO/Handle.pm>
# loading-file <Symbol.pm>
# loaded-file <Symbol.pm>
# loading-file <SelectSaver.pm>
# loaded-file <SelectSaver.pm>
# loading-file <IO.pm>
# loading-file <XSLoader.pm>
# loaded-file <XSLoader.pm>
# loaded-file <IO.pm>
# loaded-file <IO/Handle.pm>
# loading-file <Socket.pm>
# loaded-file <Socket.pm>
# loaded-file <IO/Socket.pm>
# loading-file <IO/Socket/INET.pm>
# loading-file <Exporter/Heavy.pm>
# loaded-file <Exporter/Heavy.pm>
# loaded-file <IO/Socket/INET.pm>
# loading-file <IO/Socket/UNIX.pm>
# loaded-file <IO/Socket/UNIX.pm>
# loaded-file <HTTP/Tiny.pm>
# loading-file <run/dtrace.pl>
#
# '
# expected /(?^s​:loaded-file <strict\.pm>.*loaded-file
<HTTP/Tiny\.pm>.*loaded-file <run/dtrace\.pl>)/
run/dtrace.t .. Failed 1/9 subtests

Test Summary Report


run/dtrace.t (Wstat​: 0 Tests​: 9 Failed​: 1)
  Failed test​: 9
Files=1, Tests=9, 10 wallclock secs ( 0.02 usr 0.01 sys + 0.82 cusr
0.85 csys = 1.70 CPU)
Result​: FAIL

Sometimes two tests fail. It seems to have to do with run/dtrace.pl
only appearing in with ‘loading’, not with ‘loaded’.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Jun 5, 2013

From @cpansprout

Inline Patch
diff --git a/cop.h b/cop.h
index 94a1267..122e2d7 100644
--- a/cop.h
+++ b/cop.h
@@ -581,7 +581,9 @@ struct block_format {
  * decremented by LEAVESUB, the other by LEAVE. */
 
 #define PUSHSUB_BASE(cx)						\
-	ENTRY_PROBE(GvENAME(CvGV(cv)),		       			\
+	ENTRY_PROBE(CvNAMED(cv)						\
+			? HEK_KEY(CvNAME_HEK(cv))			\
+			: GvENAME(CvGV(cv)),	       			\
 		CopFILE((const COP *)CvSTART(cv)),			\
 		CopLINE((const COP *)CvSTART(cv)),			\
 		CopSTASHPV((const COP *)CvSTART(cv)));			\
@@ -646,7 +648,9 @@ struct block_format {
 
 #define POPSUB(cx,sv)							\
     STMT_START {							\
-	RETURN_PROBE(GvENAME(CvGV((const CV*)cx->blk_sub.cv)),		\
+	RETURN_PROBE(CvNAMED(cx->blk_sub.cv)				\
+			? HEK_KEY(CvNAME_HEK(cx->blk_sub.cv))		\
+			: GvENAME(CvGV(cx->blk_sub.cv)),		\
 		CopFILE((COP*)CvSTART((const CV*)cx->blk_sub.cv)),	\
 		CopLINE((COP*)CvSTART((const CV*)cx->blk_sub.cv)),	\
 		CopSTASHPV((COP*)CvSTART((const CV*)cx->blk_sub.cv)));	\

@p5pRT
Copy link
Author

p5pRT commented Jun 5, 2013

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

@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2013

From @cpansprout

On Tue Jun 04 23​:40​:34 2013, sprout wrote​:

On Tue Jun 04 11​:48​:38 2013, rjbs wrote​:

This is a bug report for perl from rjbs@​cpan.org,
generated with the help of perlbug 1.39 running under perl 5.19.1.

-----------------------------------------------------------------
[Please describe your issue here]

I have compiled blead (929c6ec) -Dusedtrace and run​:

./perl -Ilib -E 'use feature "lexical_subs"; my sub x { say 1 }
while (1) { sleep 1; x; }'

This starts emitting a slow steady stream of ones. It is just fine.

After a while, I run​:

sudo dtrace -Zn 'perl​::sub-entry /execname == "perl"/ { }'
dtrace​: description 'perl​::sub-entry ' matched 4 probes

The original perl program segfaults within a second.

The attached patch seems to do the trick. I don’t know dtrace well
enough to write a test for it. It also happens that t/run/dtrace.t is
failing for me right now (at 35e3dd0)​:

I have applied the patch as 88dbe4a, but it still needs tests.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2013

From @rjbs

Thanks. I had been holding off until I tried writing tests, but I'm happy to see it applied, too.

--
rjbs

@p5pRT
Copy link
Author

p5pRT commented Oct 3, 2013

From @jkeenan

On Fri Jun 21 12​:55​:56 2013, rjbs wrote​:

Thanks. I had been holding off until I tried writing tests, but I'm
happy to see it applied, too.

May I dissent?

It seems that whatever test we write will require 'skip unless dtrace
present'. Whoever writes the test will need to know about dtrace (which
I do not). My hunch is that if we don't find someone to write the tests
*now*, it will never get done!

Thank you very much.
Jim Keenan

@p5pRT
Copy link
Author

p5pRT commented Oct 3, 2013

From @rjbs

* James E Keenan via RT <perlbug-followup@​perl.org> [2013-10-02T21​:34​:09]

On Fri Jun 21 12​:55​:56 2013, rjbs wrote​:

Thanks. I had been holding off until I tried writing tests, but I'm
happy to see it applied, too.

May I dissent?

It seems that whatever test we write will require 'skip unless dtrace
present'. Whoever writes the test will need to know about dtrace (which
I do not). My hunch is that if we don't find someone to write the tests
*now*, it will never get done!

It used to segfault. Now it does not. The ticket is still open so that we can
get an automated test, but are you suggested we revert the merge until we can
write one, and leave a known segfault in place?

--
rjbs

@p5pRT
Copy link
Author

p5pRT commented Oct 3, 2013

From @jkeenan

On 10/2/13 9​:49 PM, Ricardo Signes wrote​:

* James E Keenan via RT<perlbug-followup@​perl.org> [2013-10-02T21​:34​:09]

On Fri Jun 21 12​:55​:56 2013, rjbs wrote​:

Thanks. I had been holding off until I tried writing tests, but I'm
happy to see it applied, too.

May I dissent?

It seems that whatever test we write will require 'skip unless dtrace
present'. Whoever writes the test will need to know about dtrace (which
I do not). My hunch is that if we don't find someone to write the tests
*now*, it will never get done!

It used to segfault. Now it does not. The ticket is still open so that we can
get an automated test, but are you suggested we revert the merge until we can
write one, and leave a known segfault in place?

No, I'm suggesting that we not delay in figuring out who can write a
test for this -- so that we avoid a TODO in the test suite.

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

2 participants