Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: DynaLoader Problem with Perl v5.14.2 threaded ...

9 views
Skip to first unread message

Dave Mitchell

unread,
Feb 29, 2012, 11:21:15 AM2/29/12
to Norbert Gruener, perl5-...@perl.org, bulk 88
On Wed, Feb 29, 2012 at 10:57:43AM +0100, Norbert Gruener wrote:
> On Mon, Feb 27 2012, Norbert Gruener wrote:
> >
> > But with "v5.14.2-threaded" I have problems while loading the module.
> > When I run the attached script "AFS.t" I get the following error message
>
> Now I have cut down my Perl files to a few lines to show the problem.
> The attached tar file contains all necessary files.
>
> In my test environment I have compiled the "v5.14.2-threaded" with
> DEBUG option and activated the environment variable "PERL_DL_DEBUG".
> Then I get the following error message
>
> ~>/tmp/perl_thread/bin/perl Makefile.PL
> ~>make
> ~>/tmp/perl_thread/bin/perl AFS.t
> DynaLoader.pm loaded (/home/nog/develop/afsperl/latest/blib/arch /home/nog/develop/afsperl/latest/blib/lib ../../inc ../inc ./inc /tmp/perl_thread/lib/site_perl/5.14.2/i686-linux-thread-multi /tmp/perl_thread/lib/site_perl/5.14.2 /tmp/perl_thread/lib/5.14.2/i686-linux-thread-multi /tmp/perl_thread/lib/5.14.2 ., /usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib)
> DynaLoader::bootstrap for AFS (auto/AFS/AFS.so)
> BOOT-DEBUG-1
> perl: av.c:730: Perl_av_len: Assertion `((svtype)((av)->sv_flags & 0xff)) == SVt_PVAV' failed.
>
> But this problem occurs only with "v5.14.2-threaded".
>
> Am I doing something stupid or is there a problem with Perl
> "v5.14.2-threaded"?

I can't reproduce this with a debugging, threaded 5.14.2, nor does
valgrind show anything amiss:


$ PERL_DL_DEBUG=1 perl5142t AFS.t
DynaLoader.pm loaded (/home/davem/tmp/x/AFS/blib/arch /home/davem/tmp/x/AFS/blib/lib /home/davem/perl5/a/perl-5.14.2t.out/lib/site_perl/5.14.2/x86_64-linux-thread-multi /home/davem/perl5/a/perl-5.14.2t.out/lib/site_perl/5.14.2 /home/davem/perl5/a/perl-5.14.2t.out/lib/5.14.2/x86_64-linux-thread-multi /home/davem/perl5/a/perl-5.14.2t.out/lib/5.14.2 ., /usr/local/lib /lib/../lib64 /usr/lib/../lib64 /lib /usr/lib /lib64 /usr/lib64 /usr/local/lib64)
DynaLoader::bootstrap for AFS (auto/AFS/AFS.so)
BOOT-DEBUG-1
$

I'd be suspicious that something in your path or environment is being
picked up; in particular, I'd be suspicious of ../../inc etc.
Alternatively, that there's something left over from a previous build of
perl under /tmp/perl_thread; did you completely clean this directory
before building 5.14.2?

Can you show the output of

$ /tmp/perl_thread/bin/perl -V

and also run

$ valgrind /tmp/perl_thread/bin/perl AFS.t



--
Atheism is a religion like not collecting stamps is a hobby

Reini Urban

unread,
Feb 29, 2012, 12:45:33 PM2/29/12
to Norbert Gruener, perl5-...@perl.org, bulk 88
On Wed, Feb 29, 2012 at 3:57 AM, Norbert Gruener
<n...@mpa-garching.mpg.de> wrote:
> On Mon, Feb 27 2012, Norbert Gruener wrote:
>>
>> But with "v5.14.2-threaded" I have problems while loading the module.
>> When I run the attached script "AFS.t" I get the following error message
>
> Now I have cut down my Perl files to a few lines to show the problem.
> The attached tar file contains all necessary files.
>
> In my test environment I have compiled the "v5.14.2-threaded" with
> DEBUG option and activated the environment variable "PERL_DL_DEBUG".
> Then I get the following error message
>
> ~>/tmp/perl_thread/bin/perl Makefile.PL
> ~>make
> ~>/tmp/perl_thread/bin/perl AFS.t
>  DynaLoader.pm loaded (/home/nog/develop/afsperl/latest/blib/arch /home/nog/develop/afsperl/latest/blib/lib ../../inc ../inc ./inc /tmp/perl_thread/lib/site_perl/5.14.2/i686-linux-thread-multi /tmp/perl_thread/lib/site_perl/5.14.2 /tmp/perl_thread/lib/5.14.2/i686-linux-thread-multi /tmp/perl_thread/lib/5.14.2 ., /usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib)
>  DynaLoader::bootstrap for AFS (auto/AFS/AFS.so)
>  BOOT-DEBUG-1
>  perl: av.c:730: Perl_av_len: Assertion `((svtype)((av)->sv_flags & 0xff)) == SVt_PVAV' failed.
>
> But this problem occurs only with "v5.14.2-threaded".
>
> Am I doing something stupid or is there a problem with Perl
> "v5.14.2-threaded"?

The symptoms look similar to this solaris 64-bit threaded bug here
https://rt.perl.org/rt3/Ticket/Display.html?id=91678

5.14.0 threaded 64-bit stopped working, last working was 5.12.4.
5.15.6 still failed, v5.15.8-24-g236cbe8 fixed the problem for the reporter.
I could repro it with suncc static libperl but had no time and vm
space left yet to investigate. ZFS is a dog.
With gcc I got different relocation errors as in the ticket.
--
Reini Urban
http://cpanel.net/   http://www.perl-compiler.org/

Norbert Gruener

unread,
Mar 1, 2012, 2:59:51 AM3/1/12
to perl5-...@perl.org, Dave Mitchell, bulk 88
Hi Dave,

thank you for your time.
As I can see from your output, you are running your test on 64-bit
platform. I was running under 32-bit.

Now I have tested it under 64-bit too and it is working for me too.


*** But the problem still exists on the *** 32-bit *** platform. ***


> I'd be suspicious that something in your path or environment is being
> picked up; in particular, I'd be suspicious of ../../inc etc.

I have removed the "use lib qw(./inc)" line from the "Makefile.PL",
but there is no difference.

> Alternatively, that there's something left over from a previous build of
> perl under /tmp/perl_thread; did you completely clean this directory
> before building 5.14.2?

I have redone my tests right now

I have removed all old directories for the source code and for the
installation.

I have installed a fresh perl5 v5.14.2-threaded in "/tmp/perl_thread".
rm -rf perl-5.14.2
tar zxvf perl-5.14.2.tar.gz
cd perl-5.14.2
sh Configure -Dprefix=/tmp/perl_thread -Dusethreads -DDEBUGGING=both -des
make install

I have made my tests again
cd ext/AFS/
/tmp/perl_thread/bin/perl Makefile.PL
make
/tmp/perl_thread/bin/perl AFS.t

And I can still reproduce my problem.

I can even reproduce that problem on two different machines (my
laptop and my desktop machine at my office). On both machines the
perl5 v5.14.2-threaded where installed from fresh. On my office
machine it is installed under "perlbrew".


> Can you show the output of
>
> $ /tmp/perl_thread/bin/perl -V

This is the output from my laptop:
----------------------------------
/tmp/perl_thread/bin/perl -V
Summary of my perl5 (revision 5 version 14 subversion 2) configuration:

Platform:
osname=linux, osvers=2.6.26-2-686, archname=i686-linux-thread-multi
uname='linux samx3 2.6.26-2-686 #1 smp sat dec 26 09:01:51 utc 2009 i686 gnulinux '
config_args='-Dprefix=/tmp/perl_thread -Dusethreads -DDEBUGGING=both -des'
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 ='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2 -g',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
ccversion='', gccversion='4.3.2', 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 =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib
libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
libc=/lib/libc-2.7.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.7'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -g -L/usr/local/lib -fstack-protector'


Characteristics of this binary (from libperl):
Compile-time options: DEBUGGING MULTIPLICITY PERL_DONT_CREATE_GVSV
PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
PERL_PRESERVE_IVUV PERL_TRACK_MEMPOOL USE_ITHREADS
USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF
USE_REENTRANT_API
Built under linux
Compiled at Mar 1 2012 08:32:41
@INC:
/tmp/perl_thread/lib/site_perl/5.14.2/i686-linux-thread-multi
/tmp/perl_thread/lib/site_perl/5.14.2
/tmp/perl_thread/lib/5.14.2/i686-linux-thread-multi
/tmp/perl_thread/lib/5.14.2
.


This is the output from my desktop (under perlbrew):
----------------------------------------------------
~/ext/AFS>perl -V
Summary of my perl5 (revision 5 version 14 subversion 2) configuration:

Platform:
osname=linux, osvers=2.6.37.6, archname=i686-linux-thread-multi
uname='linux mpadmz-4 2.6.37.6 #1 smp preempt fri apr 1 11:31:01 cest 2011 i686 gnulinux '
config_args='-de -Dprefix=/afs/mpa/home/nog/perl5/perlbrew/perls/perl-5.14.2-thread -Dusethreads'
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 ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
ccversion='', gccversion='4.5.2', 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 =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
libc=/lib/libc-2.11.3.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.11.3'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector'


Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
PERL_PRESERVE_IVUV USE_ITHREADS USE_LARGE_FILES
USE_PERLIO USE_PERL_ATOF USE_REENTRANT_API
Built under linux
Compiled at Jan 26 2012 11:14:04
%ENV:
PERLBREW_CSHRC_VERSION="0.40"
PERLBREW_HOME="/afs/mpa/home/nog/.perlbrew"
PERLBREW_MANPATH="/afs/mpa/home/nog/perl5/perlbrew/perls/perl-5.14.2-thread/man"
PERLBREW_PATH="/afs/mpa/home/nog/perl5/perlbrew/bin:/afs/mpa/home/nog/perl5/perlbrew/perls/perl-5.14.2-thread/bin"
PERLBREW_PERL="perl-5.14.2-thread"
PERLBREW_ROOT="/afs/mpa/home/nog/perl5/perlbrew"
PERLBREW_SKIP_INIT="1"
PERLBREW_VERSION="0.40"
PERL_DL_DEBUG="1"
@INC:
/afs/mpa/home/nog/perl5/perlbrew/perls/perl-5.14.2-thread/lib/site_perl/5.14.2/i686-linux-thread-multi
/afs/mpa/home/nog/perl5/perlbrew/perls/perl-5.14.2-thread/lib/site_perl/5.14.2
/afs/mpa/home/nog/perl5/perlbrew/perls/perl-5.14.2-thread/lib/5.14.2/i686-linux-thread-multi
/afs/mpa/home/nog/perl5/perlbrew/perls/perl-5.14.2-thread/lib/5.14.2

> and also run
>
> $ valgrind /tmp/perl_thread/bin/perl AFS.t

I have to install valgrind first. When I have the "valgrind" output I
will send it.

Cheers,

Norbert
--
Ceterum censeo
Redmond esse delendam.

Reini Urban

unread,
Mar 1, 2012, 10:40:05 AM3/1/12
to Norbert Gruener, perl5-...@perl.org, Dave Mitchell, bulk 88
On Thu, Mar 1, 2012 at 1:59 AM, Norbert Gruener <n...@mpa-garching.mpg.de> wrote:
> /tmp/perl_thread/bin/perl AFS.t

What does gdb --args /tmp/perl_thread/bin/perl AFS.t
give you? After the AV assertion, please investigate the value of av.

(gdb) bt
...go up to the assert
(gdb) p/x av
(gdb) p Perl_sv_dump(my_perl, av)


PS:
Please improve your detection methods.
e.g. src/Makefile.PL:
if ($archname =~ /thread/i) {
=>
if ($Config{usethreads}) {

"-threads" is not guaranteed to be in archname at all.

The rest hurts my eye.

Norbert Gruener

unread,
Mar 2, 2012, 5:48:56 AM3/2/12
to perl5-...@perl.org, Dave Mitchell, bulk 88
Please find attached the output from valgrind.
zzz.assert

Dave Mitchell

unread,
Mar 2, 2012, 6:26:01 AM3/2/12
to Norbert Gruener, perl5-...@perl.org, bulk 88
On Fri, Mar 02, 2012 at 11:48:56AM +0100, Norbert Gruener wrote:
> Please find attached the output from valgrind.

PS - I can reproduce this now and am looking into it further.

--
You live and learn (although usually you just live).

Norbert Gruener

unread,
Mar 2, 2012, 7:55:47 AM3/2/12
to perl5-...@perl.org, Dave Mitchell, Reini Urban
On Fri, Mar 02 2012, Dave Mitchell wrote:
> On Fri, Mar 02, 2012 at 11:48:56AM +0100, Norbert Gruener wrote:
> > Please find attached the output from valgrind.
>
> PS - I can reproduce this now and am looking into it further.

Thank your ...

Norbert Gruener

unread,
Mar 2, 2012, 8:31:16 AM3/2/12
to Reini Urban, perl5-...@perl.org, Dave Mitchell
On Thu, Mar 01 2012, Reini Urban wrote:
> On Thu, Mar 1, 2012 at 1:59 AM, Norbert Gruener <n...@mpa-garching.mpg.de> wrote:
> > /tmp/perl_thread/bin/perl AFS.t
>
> What does gdb --args /tmp/perl_thread/bin/perl AFS.t
> give you? After the AV assertion, please investigate the value of av.
>
> (gdb) bt

Backtrace
---------
(gdb) bt
#0 0xb7f2f424 in __kernel_vsyscall ()
#1 0xb7d5b640 in raise () from /lib/i686/cmov/libc.so.6
#2 0xb7d5d018 in abort () from /lib/i686/cmov/libc.so.6
#3 0xb7d545be in __assert_fail () from /lib/i686/cmov/libc.so.6
#4 0x0813ee68 in Perl_av_len (my_perl=0x5993, av=0x0) at av.c:730
#5 0x08083619 in Perl_call_list (my_perl=0x92f2008, oldscope=9, paramList=0x92f581c)
at perl.c:4688
#6 0xb7f278b2 in boot_AFS (my_perl=0x92f2008, cv=0x939c0f4) at AFS.c:133
#7 0x081462ce in Perl_pp_entersub (my_perl=0x92f2008) at pp_hot.c:3046
#8 0x08107919 in Perl_runops_debug (my_perl=0x92f2008) at dump.c:2266
#9 0x0808303b in Perl_call_sv (my_perl=0x92f2008, sv=0x9311b24, flags=14) at perl.c:2647
#10 0x080839bd in Perl_call_list (my_perl=0x92f2008, oldscope=2, paramList=0x9311ba4)
at perl.c:4714
#11 0x08062369 in S_process_special_blocks (my_perl=0x92f2008,
fullname=<value optimized out>, gv=0x9311b84, cv=0x9311b24) at op.c:6462
#12 0x08076f1f in Perl_newATTRSUB (my_perl=0x92f2008, floor=38, o=0x9318a38, proto=0x0,
attrs=0x0, block=0x936aeb8) at op.c:6433
#13 0x080780c3 in Perl_utilize (my_perl=0x92f2008, aver=1, floor=38, version=0x0,
idop=0x93187e8, arg=0x0) at op.c:4309
#14 0x080cd00c in Perl_yyparse (my_perl=0x92f2008, gramtype=258) at perly.y:361
#15 0x08086d9d in S_parse_body (my_perl=0x92f2008, env=0x0, xsinit=0x805fe50 <xs_init>)
at perl.c:2194
#16 0x08088404 in perl_parse (my_perl=0x92f2008, xsinit=0x805fe50 <xs_init>, argc=2,
argv=0xbfabea34, env=0x0) at perl.c:1613
#17 0x0805fd93 in main (argc=2, argv=0xbfabea34, env=0xbfabea40) at perlmain.c:118

> ...go up to the assert
> (gdb) p/x av

(gdb) up 4
#4 0x0813ee68 in Perl_av_len (my_perl=0x59c7, av=0x0) at av.c:730
730 assert(SvTYPE(av) == SVt_PVAV);
(gdb) p/x av
$1 = 0x0

> (gdb) p Perl_sv_dump(my_perl, av)

(gdb) p Perl_sv_dump(my_perl, av)

Program received signal SIGSEGV, Segmentation fault.
Perl_sv_dump (my_perl=0x59c7, sv=0x0) at dump.c:2230
2230 if (SvROK(sv))
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on"
Evaluation of the expression containing the function (Perl_sv_dump) will be abandoned.

> PS:
> Please improve your detection methods.
> e.g. src/Makefile.PL:
> if ($archname =~ /thread/i) {
> =>
> if ($Config{usethreads}) {
>
> "-threads" is not guaranteed to be in archname at all.

Thank you for your suggestion. I will implement it.

> The rest hurts my eye.

I am really sorry to hurt your eyes :-)
But that code is historically grown over nearly ten years now. I am
aware that I need a complete rewrite of that "Makefile.PL". I will
tackle that task when I adapt my module for "64-bit platforms and
threaded Perl".

Nevertheless I want to say thank you that you are taking your time for
looking into my problem.

Dave Mitchell

unread,
Mar 2, 2012, 8:45:36 AM3/2/12
to Norbert Gruener, perl5-...@perl.org, bulk 88
On Fri, Mar 02, 2012 at 11:26:01AM +0000, Dave Mitchell wrote:
> On Fri, Mar 02, 2012 at 11:48:56AM +0100, Norbert Gruener wrote:
> > Please find attached the output from valgrind.
>
> PS - I can reproduce this now and am looking into it further.

I've located the proximate source of your problem in the sample code.

Your Makefile.PL has

'CCFLAGS' => '-Wall',

which overrides the normal cc flags which were used to build perl.
The perl .o files got compiled (on my system at least) with
-D_FILE_OFFSET_BITS=64 on the command line, while your AFS.o doesn't.
This ends up causing perl's and AFS.o's idea of the size and alignment of
the my_perl variable to differ (due to different sizes of st_size from
stat.t).

As to what the fix is, and whether perl is doing anything wrong, I don't
really know (the build system isn't my area of expertise).


--
Never work with children, animals, or actors.

Norbert Gruener

unread,
Mar 4, 2012, 5:01:58 AM3/4/12
to Dave Mitchell, perl5-...@perl.org, bulk 88, Reini Urban
Hi Dave,

thank you very much for your precious help.

On Fri, Mar 02 2012, Dave Mitchell wrote:
> On Fri, Mar 02, 2012 at 11:26:01AM +0000, Dave Mitchell wrote:
> > On Fri, Mar 02, 2012 at 11:48:56AM +0100, Norbert Gruener wrote:
> > > Please find attached the output from valgrind.
> >
> > PS - I can reproduce this now and am looking into it further.
>
> I've located the proximate source of your problem in the sample code.
>
> Your Makefile.PL has
>
> 'CCFLAGS' => '-Wall',
>
> which overrides the normal cc flags which were used to build perl.

You are right, this is the key to my problem. I have modified that
statement in the meantime by

my $ccflags = $Config::Config{ccflags} || '';
my %MakefileArgs = ( 'CCFLAGS' => "-Wall $ccflags",

and now everything works perfectly fine.

Once more, thank you very much for your help, Dave. And I want to
thank all the other contributors who took their time to investigate my
problem.
0 new messages