Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.88k stars 530 forks source link

threads::shared use of XSLoader breaks Devel::DProf #7320

Open p5pRT opened 20 years ago

p5pRT commented 20 years ago

Migrated from rt.perl.org#29939 (status was 'stalled')

Searchable as RT29939$

p5pRT commented 20 years ago

From beeman@spl.at

This is a bug report for perl from beeman@​spl.at\, generated with the help of perlbug 1.35 running under perl v5.8.4.


I can't run the Devel​::DProf profiler on any script that uses threads/shared.pm\, because that lib loads itself using XSLoader​::load(). This function is written such that it bumps up against a DProf bug\, whereby it chokes on subroutines that end with a last\, goto\, or next. In XSLoader.pm​:

From XSLoader​::load​: ...   # See comment block above   return &$xs(@​_);

  retry​:   require DynaLoader;   goto &DynaLoader​::bootstrap_inherit; }

The result​: % ~/bin/perl-5.8.4/bin/perl -d​:DProf ~/tmp/thread_test.pl panic​: Devel​::DProf inconsistent subroutine return at /usr/bcstrong/bin/perl-5.8.4/lib/5.8.4/i686-linux-thread-multi/threads/shared.pm line 18. BEGIN failed--compilation aborted at /usr/bcstrong/bin/perl-5.8.4/lib/5.8.4/i686-linux-thread-multi/threads/shared.pm line 35. Compilation failed in require at /usr/bcstrong/tmp/thread_test.pl line 5. BEGIN failed--compilation aborted at /usr/bcstrong/tmp/thread_test.pl line 5.

Predictably\, if I comment out "use threads​::shared" (plus any shared variable declarations)\, it runs fine.

I suppose that if this problem is going to be fixed in DProf then this is just a duplicate bug\, but I would suggest that this issue increases the severity\, since the major question marks about ithreads seems to revolve around memory usage\, which DProf is useful for checking.



Flags​:   category=library   severity=low


Site configuration information for perl v5.8.4​:

Configured by bcstrong at Mon May 24 14​:47​:16 PDT 2004.

Summary of my perl5 (revision 5 version 8 subversion 4) configuration​:   Platform​:   osname=linux\, osvers=2.4.9-45lxset12smp\, archname=i686-linux-thread-multi   uname='linux plxc3752 2.4.9-45lxset12smp #1 smp tue jan 27 00​:35​:25 pst 2004 i686 unknown '   config_args='-Duseithreads'   hint=recommended\, useposix=true\, d_sigaction=define   usethreads=define use5005threads=undef 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 ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm'\,   optimize='-O2'\,   cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -I/usr/local/include -I/usr/include/gdbm'   ccversion=''\, gccversion='2.96 20000731 (Red Hat Linux 7.1 2.96-85)'\, gccosandvers=''   intsize=4\, longsize=4\, ptrsize=4\, doublesize=8\, byteorder=1234   d_longlong=define\, longlongsize=8\, d_longdbl=define\, longdblsize=12   ivtype='long'\, ivsize=4\, nvtype='double'\, nvsize=8\, Off_t='off_t'\, lseeksize=8   alignbytes=4\, prototype=define   Linker and Libraries​:   ld='cc'\, ldflags =' -L/usr/local/lib'   libpth=/usr/local/lib /lib /usr/lib   libs=-lnsl -lndbm -lgdbm -ldl -lm -lcrypt -lutil -lpthread -lc   perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc   libc=/lib/libc-2.2.4.so\, so=so\, useshrplib=false\, libperl=libperl.a   gnulibc_version='2.2.4'   Dynamic Linking​:   dlsrc=dl_dlopen.xs\, dlext=so\, d_dlsymun=undef\, ccdlflags='-Wl\,-E'   cccdlflags='-fpic'\, lddlflags='-shared -L/usr/local/lib'

Locally applied patches​:  


@​INC for perl v5.8.4​:   /usr/bcstrong/bin/perl-5.8.4/lib/5.8.4/i686-linux-thread-multi   /usr/bcstrong/bin/perl-5.8.4/lib/5.8.4   /usr/bcstrong/bin/perl-5.8.4/lib/site_perl/5.8.4/i686-linux-thread-multi   /usr/bcstrong/bin/perl-5.8.4/lib/site_perl/5.8.4   /usr/bcstrong/bin/perl-5.8.4/lib/site_perl   .


Environment for perl v5.8.4​:   HOME=/usr/bcstrong   LANG=C   LANGUAGE (unset)   LD_LIBRARY_PATH (unset)   LOGDIR (unset)   PATH=.​:/usr/bcstrong/bin​:/usr/local/bin​:/usr/X11R6/bin​:/usr/afsws/bin​:/usr/afsws/etc​:/usr/bin/X11​:/usr/local/bin/X11R5​:/usr/ucb​:/bin​:/usr/local/frame/bin​:/usr/bin​:/usr/bin​:/usr/local/bin   PERL_BADLANG (unset)   PERL_DEBUG_MSTATS=2   SHELL=/usr/bin/tcsh

p5pRT commented 20 years ago

From @iabyn

On Fri\, May 28\, 2004 at 11​:07​:28PM -0000\, Norbert wrote​:

I can't run the Devel​::DProf profiler on any script that uses threads/shared.pm\, because that lib loads itself using XSLoader​::load(). This function is written such that it bumps up against a DProf bug\, whereby it chokes on subroutines that end with a last\, goto\, or next. (snip) I suppose that if this problem is going to be fixed in DProf then this is just a duplicate bug\, but I would suggest that this issue increases the severity\, since the major question marks about ithreads seems to revolve around memory usage\, which DProf is useful for checking.

Thanks for the report. yes\, this does seem to be the same problem.

P5Pers​: the root problem seems to be that whenever pp_entersub is invoked\, it calls DB​::sub rather than the the real sub\, and it is left to DB​::sub to then invoke the real sub\, which can be tricky when that real sub may do various stuff that will unwind the CX stack (like goto &foo\, last\, die).

I'd have thought a better way would be to provide an additional C-level hook that gets called by entersub before it (ie entersub) then proceeds to call the real sub as usual.

I havn't looked into this closely\, though. I'm hoping someone with some more experience in this area might comment.

Dave.

-- The Enterprise is involved in a bizarre time-warp experience which is in some way unconnected with the Late 20th Century.   -- Things That Never Happen in "Star Trek" #14

p5pRT commented 20 years ago

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

p5pRT commented 12 years ago

From @jkeenan

On Sun May 30 15​:39​:00 2004\, davem@​iabyn.com wrote​:

On Fri\, May 28\, 2004 at 11​:07​:28PM -0000\, Norbert wrote​:

I can't run the Devel​::DProf profiler on any script that uses threads/shared.pm\, because that lib loads itself using XSLoader​::load(). This function is written such that it bumps up against a DProf bug\, whereby it chokes on subroutines that end with a last\, goto\, or next. (snip) I suppose that if this problem is going to be fixed in DProf then this is just a duplicate bug\, but I would suggest that this issue increases the severity\, since the major question marks about ithreads seems to revolve around memory usage\, which DProf is useful for checking.

Thanks for the report. yes\, this does seem to be the same problem.

P5Pers​: the root problem seems to be that whenever pp_entersub is invoked\, it calls DB​::sub rather than the the real sub\, and it is left to DB​::sub to then invoke the real sub\, which can be tricky when that real sub may do various stuff that will unwind the CX stack (like goto &foo\, last\, die).

I'd have thought a better way would be to provide an additional C-level hook that gets called by entersub before it (ie entersub) then proceeds to call the real sub as usual.

I havn't looked into this closely\, though. I'm hoping someone with some more experience in this area might comment.

Dave.

Discussion in this RT petered out eight years ago\, and Devel​::DProf was removed from the Perl core distribution with Perl 5.15.9.

How should we handle this ticket?

Thank you very much. Jim Keenan

p5pRT commented 12 years ago

From @cpansprout

On Sat May 26 18​:55​:06 2012\, jkeenan wrote​:

On Sun May 30 15​:39​:00 2004\, davem@​iabyn.com wrote​:

On Fri\, May 28\, 2004 at 11​:07​:28PM -0000\, Norbert wrote​:

I can't run the Devel​::DProf profiler on any script that uses threads/shared.pm\, because that lib loads itself using XSLoader​::load(). This function is written such that it bumps up against a DProf bug\, whereby it chokes on subroutines that end with a last\, goto\, or next. (snip) I suppose that if this problem is going to be fixed in DProf then this is just a duplicate bug\, but I would suggest that this issue increases the severity\, since the major question marks about ithreads seems to revolve around memory usage\, which DProf is useful for checking.

Thanks for the report. yes\, this does seem to be the same problem.

P5Pers​: the root problem seems to be that whenever pp_entersub is invoked\, it calls DB​::sub rather than the the real sub\, and it is left to DB​::sub to then invoke the real sub\, which can be tricky when that real sub may do various stuff that will unwind the CX stack (like goto &foo\, last\, die).

I'd have thought a better way would be to provide an additional C-level hook that gets called by entersub before it (ie entersub) then proceeds to call the real sub as usual.

I havn't looked into this closely\, though. I'm hoping someone with some more experience in this area might comment.

Dave.

Discussion in this RT petered out eight years ago\, and Devel​::DProf was removed from the Perl core distribution with Perl 5.15.9.

How should we handle this ticket?

I sounds to me as though the perl core might require some fixing. So someone needs to look into it at some point. So I suggest we leave it open.

--

Father Chrysostomos

p5pRT commented 8 years ago

@dcollinsn - Status changed from 'open' to 'stalled'