Skip Menu |
 
Report information
Id: 120888
Status: resolved
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: nullnilaki [at] gmail.com
Cc:
AdminCc:

Operating System: netbsd
PatchStatus: (no value)
Severity: critical
Type: core
Perl Version: 5.18.1
Fixed In: (no value)



Date: Sat, 28 Dec 2013 22:05:14 +0900
CC: 江富功朗 <nullnilaki [...] gmail.com>
From: 江富功朗 <nullnilaki [...] gmail.com>
To: perlbug [...] perl.org
Subject: scope.c cause an unaligned access exception.
Download (untitled) / with headers
text/plain 3.2k
This is a bug report for perl from nullnilaki@gmail.com, generated with the help of perlbug 1.39 running under perl 5.18.1. ----------------------------------------------------------------- [Please describe your issue here] I am using Netbsd/alpha. perl cause an unaligned access exception. Core was generated by `perl'. Program terminated with signal 10, Bus error. #0 0x00000001601795c8 in Perl_leave_scope (my_perl=0x160505000, base=<optimized out>) at scope.c:1217 1217 *(I8*)ARG0_PTR = (I8)(uv >> 8); Taking a picture http://p.twipple.jp/Rh2K4 http://twitpic.com/dqa7uh [Please do not change anything below this line] ----------------------------------------------------------------- --- Flags: category=core severity=critical --- Site configuration information for perl 5.18.1: Configured by naruaki at Sat Dec 28 11:15:19 UTC 2013. Summary of my perl5 (revision 5 version 18 subversion 1) configuration: Platform: osname=netbsd, osvers=6.1.2, archname=alpha-netbsd-thread-multi uname='netbsd 6.1.2 netbsd 6.1.2 (generic-$revision: 1.343 $) #13: sat dec 7 08:25:52 jst 2013 naruaki@netbsd:usrnetbsd_6_1_2obj.alphasysarchalphacompilegeneric alpha ' config_args='-sde -Duseshrplib -Duseithreads -Uusemymalloc' hint=recommended, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-O2 -mieee -g -pthread -I/usr/include -fno-strict-aliasing -pipe -I/usr/pkg/include', optimize='-O2 -mieee -g -pthread -I/usr/include', cppflags='-O2 -mieee -g -pthread -I/usr/include -fno-strict-aliasing -pipe -I/usr/pkg/include' ccversion='', gccversion='4.5.3', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='cc', ldflags ='-Wl,-rpath,/usr/pkg/lib -L/usr/pkg/lib' libpth=/lib /usr/lib /usr/pkg/lib libs=-lm -lcrypt -lpthread perllibs=-lm -lcrypt -lpthread libc=/lib/libc.so, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-R/usr/pkg/lib/perl5/5.18.0/alpha-netbsd-thread-multi/CORE' cccdlflags='-DPIC -fPIC ', lddlflags='-shared -L/usr/pkg/lib' Locally applied patches: --- @INC for perl 5.18.1: /usr/pkg/lib/perl5/site_perl/5.18.0/alpha-netbsd-thread-multi /usr/pkg/lib/perl5/site_perl/5.18.0 /usr/pkg/lib/perl5/vendor_perl/5.18.0/alpha-netbsd-thread-multi /usr/pkg/lib/perl5/vendor_perl/5.18.0 /usr/pkg/lib/perl5/5.18.0/alpha-netbsd-thread-multi /usr/pkg/lib/perl5/5.18.0 . --- Environment for perl 5.18.1: HOME=/home/naruaki LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/home/naruaki/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R7/bin:/usr/X11R6/bin:/usr/pkg/bin:/usr/pkg/sbin:/usr/games:/usr/local/bin:/usr/local/sbin PERL_BADLANG (unset) SHELL=/bin/sh
From: demerphq <demerphq [...] gmail.com>
Subject: Re: [perl #120888] scope.c cause an unaligned access exception.
To: Perl5 Porteros <perl5-porters [...] perl.org>
Date: Sat, 28 Dec 2013 18:33:53 +0100
Download (untitled) / with headers
text/plain 3.8k
You need to provide us a replication script. On 28 December 2013 14:05, 江富功朗 <perlbug-followup@perl.org> wrote: Show quoted text
> # New Ticket Created by 江富功朗 > # Please include the string: [perl #120888] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=120888 > > > > This is a bug report for perl from nullnilaki@gmail.com, > generated with the help of perlbug 1.39 running under perl 5.18.1. > > > ----------------------------------------------------------------- > [Please describe your issue here] > I am using Netbsd/alpha. > perl cause an unaligned access exception. > > Core was generated by `perl'. > Program terminated with signal 10, Bus error. > #0 0x00000001601795c8 in Perl_leave_scope (my_perl=0x160505000, > base=<optimized out>) at scope.c:1217 > 1217 *(I8*)ARG0_PTR = (I8)(uv >> 8); > > Taking a picture > http://p.twipple.jp/Rh2K4 > http://twitpic.com/dqa7uh > > [Please do not change anything below this line] > ----------------------------------------------------------------- > --- > Flags: > category=core > severity=critical > --- > Site configuration information for perl 5.18.1: > > Configured by naruaki at Sat Dec 28 11:15:19 UTC 2013. > > Summary of my perl5 (revision 5 version 18 subversion 1) configuration: > > Platform: > osname=netbsd, osvers=6.1.2, archname=alpha-netbsd-thread-multi > uname='netbsd 6.1.2 netbsd 6.1.2 (generic-$revision: 1.343 $) #13: > sat dec 7 08:25:52 jst 2013 > naruaki@netbsd:usrnetbsd_6_1_2obj.alphasysarchalphacompilegeneric > alpha ' > config_args='-sde -Duseshrplib -Duseithreads -Uusemymalloc' > hint=recommended, useposix=true, d_sigaction=define > useithreads=define, usemultiplicity=define > useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef > use64bitint=define, use64bitall=define, uselongdouble=undef > usemymalloc=n, bincompat5005=undef > Compiler: > cc='cc', ccflags ='-O2 -mieee -g -pthread -I/usr/include > -fno-strict-aliasing -pipe -I/usr/pkg/include', > optimize='-O2 -mieee -g -pthread -I/usr/include', > cppflags='-O2 -mieee -g -pthread -I/usr/include > -fno-strict-aliasing -pipe -I/usr/pkg/include' > ccversion='', gccversion='4.5.3', gccosandvers='' > intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 > d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8 > ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', > lseeksize=8 > alignbytes=8, prototype=define > Linker and Libraries: > ld='cc', ldflags ='-Wl,-rpath,/usr/pkg/lib -L/usr/pkg/lib' > libpth=/lib /usr/lib /usr/pkg/lib > libs=-lm -lcrypt -lpthread > perllibs=-lm -lcrypt -lpthread > libc=/lib/libc.so, so=so, useshrplib=true, libperl=libperl.so > gnulibc_version='' > Dynamic Linking: > dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E > -Wl,-R/usr/pkg/lib/perl5/5.18.0/alpha-netbsd-thread-multi/CORE' > cccdlflags='-DPIC -fPIC ', lddlflags='-shared -L/usr/pkg/lib' > > Locally applied patches: > > > --- > @INC for perl 5.18.1: > /usr/pkg/lib/perl5/site_perl/5.18.0/alpha-netbsd-thread-multi > /usr/pkg/lib/perl5/site_perl/5.18.0 > /usr/pkg/lib/perl5/vendor_perl/5.18.0/alpha-netbsd-thread-multi > /usr/pkg/lib/perl5/vendor_perl/5.18.0 > /usr/pkg/lib/perl5/5.18.0/alpha-netbsd-thread-multi > /usr/pkg/lib/perl5/5.18.0 > . > > --- > Environment for perl 5.18.1: > HOME=/home/naruaki > LANG (unset) > LANGUAGE (unset) > LD_LIBRARY_PATH (unset) > LOGDIR (unset) > PATH=/home/naruaki/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R7/bin:/usr/X11R6/bin:/usr/pkg/bin:/usr/pkg/sbin:/usr/games:/usr/local/bin:/usr/local/sbin > PERL_BADLANG (unset) > SHELL=/bin/sh >
-- perl -Mre=debug -e "/just|another|perl|hacker/"
Date: Sat, 28 Dec 2013 22:44:37 -0500
From: James E Keenan <jkeen [...] verizon.net>
To: perl5-porters [...] perl.org
Subject: Re: [perl #120888] scope.c cause an unaligned access exception.
Download (untitled) / with headers
text/plain 3.9k
On 12/28/13 8:05 AM, 江富功朗 wrote: Show quoted text
> # New Ticket Created by 江富功朗 > # Please include the string: [perl #120888] > # in the subject line of all future correspondence about this issue. > #<URL: https://rt.perl.org/Ticket/Display.html?id=120888> > > > This is a bug report for perl from nullnilaki@gmail.com, > generated with the help of perlbug 1.39 running under perl 5.18.1. > > > ----------------------------------------------------------------- > [Please describe your issue here] > I am using Netbsd/alpha. > perl cause an unaligned access exception. > > Core was generated by `perl'. > Program terminated with signal 10, Bus error. > #0 0x00000001601795c8 in Perl_leave_scope (my_perl=0x160505000, > base=<optimized out>) at scope.c:1217 > 1217 *(I8*)ARG0_PTR = (I8)(uv>> 8); > > Taking a picture > http://p.twipple.jp/Rh2K4 > http://twitpic.com/dqa7uh > > [Please do not change anything below this line] > ----------------------------------------------------------------- > --- > Flags: > category=core > severity=critical > --- > Site configuration information for perl 5.18.1: > > Configured by naruaki at Sat Dec 28 11:15:19 UTC 2013. > > Summary of my perl5 (revision 5 version 18 subversion 1) configuration: > > Platform: > osname=netbsd, osvers=6.1.2, archname=alpha-netbsd-thread-multi > uname='netbsd 6.1.2 netbsd 6.1.2 (generic-$revision: 1.343 $) #13: > sat dec 7 08:25:52 jst 2013 > naruaki@netbsd:usrnetbsd_6_1_2obj.alphasysarchalphacompilegeneric > alpha ' > config_args='-sde -Duseshrplib -Duseithreads -Uusemymalloc' > hint=recommended, useposix=true, d_sigaction=define > useithreads=define, usemultiplicity=define > useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef > use64bitint=define, use64bitall=define, uselongdouble=undef > usemymalloc=n, bincompat5005=undef > Compiler: > cc='cc', ccflags ='-O2 -mieee -g -pthread -I/usr/include > -fno-strict-aliasing -pipe -I/usr/pkg/include', > optimize='-O2 -mieee -g -pthread -I/usr/include', > cppflags='-O2 -mieee -g -pthread -I/usr/include > -fno-strict-aliasing -pipe -I/usr/pkg/include' > ccversion='', gccversion='4.5.3', gccosandvers='' > intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 > d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8 > ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', > lseeksize=8 > alignbytes=8, prototype=define > Linker and Libraries: > ld='cc', ldflags ='-Wl,-rpath,/usr/pkg/lib -L/usr/pkg/lib' > libpth=/lib /usr/lib /usr/pkg/lib > libs=-lm -lcrypt -lpthread > perllibs=-lm -lcrypt -lpthread > libc=/lib/libc.so, so=so, useshrplib=true, libperl=libperl.so > gnulibc_version='' > Dynamic Linking: > dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E > -Wl,-R/usr/pkg/lib/perl5/5.18.0/alpha-netbsd-thread-multi/CORE' > cccdlflags='-DPIC -fPIC ', lddlflags='-shared -L/usr/pkg/lib' > > Locally applied patches: > > > --- > @INC for perl 5.18.1: > /usr/pkg/lib/perl5/site_perl/5.18.0/alpha-netbsd-thread-multi > /usr/pkg/lib/perl5/site_perl/5.18.0 > /usr/pkg/lib/perl5/vendor_perl/5.18.0/alpha-netbsd-thread-multi > /usr/pkg/lib/perl5/vendor_perl/5.18.0 > /usr/pkg/lib/perl5/5.18.0/alpha-netbsd-thread-multi > /usr/pkg/lib/perl5/5.18.0 > . > > --- > Environment for perl 5.18.1: > HOME=/home/naruaki > LANG (unset) > LANGUAGE (unset) > LD_LIBRARY_PATH (unset) > LOGDIR (unset) > PATH=/home/naruaki/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R7/bin:/usr/X11R6/bin:/usr/pkg/bin:/usr/pkg/sbin:/usr/games:/usr/local/bin:/usr/local/sbin > PERL_BADLANG (unset) > SHELL=/bin/sh >
Did you encounter this problem while trying to build or test perl 5.18 (i.e., during 'make' or 'make test')? Or did you encounter this problem while running a perl program after having built and installed perl? Thank you very much. Jim Keenan
Date: Sun, 29 Dec 2013 08:29:21 +0900
CC: perl5-porters [...] perl.org, demerphq [...] gmail.com
From: 江富功朗 <nullnilaki [...] gmail.com>
To: perlbug-followup [...] perl.org
Subject: Re: [perl #120888] scope.c cause an unaligned access exception.
Download (untitled) / with headers
text/plain 172.8k

Message body is not shown because it is too large.

From: 江富功朗 <nullnilaki [...] gmail.com>
Subject: Re: [perl #120888] scope.c cause an unaligned access exception.
To: perlbug-followup [...] perl.org
Date: Sun, 29 Dec 2013 03:21:19 +0900
Download (untitled) / with headers
text/plain 172.8k

Message body is not shown because it is too large.

Date: Sun, 29 Dec 2013 13:29:36 +0900
From: 江富功朗 <nullnilaki [...] gmail.com>
CC: perl5-porters [...] perl.org, Yves Orton <demerphq [...] gmail.com>, jkeen [...] verizon.net
Subject: Re: [perl #120888] scope.c cause an unaligned access exception.
To: perlbug-followup [...] perl.org
Download (untitled) / with headers
text/plain 179.6k

Message body is not shown because it is too large.

Date: Sun, 29 Dec 2013 20:07:47 +0900
From: "Naruaki.Etomi" <nullnilaki [...] gmail.com>
Subject: [perl #120888] scope.c cause an unaligned access exception.
To: perlbug-followup [...] perl.org
Download (untitled) / with headers
text/plain 172.8k

Message body is not shown because it is too large.

Subject: [perl #120888] scope.c cause an unaligned access exception.
To: perlbug-followup [...] perl.org
From: "Naruaki.Etomi" <nullnilaki [...] gmail.com>
Date: Sun, 29 Dec 2013 20:09:12 +0900
Download (untitled) / with headers
text/plain 179.6k

Message body is not shown because it is too large.

Date: Sun, 29 Dec 2013 14:22:58 +0900
From: "Naruaki.Etomi" <nullnilaki [...] gmail.com>
Subject: Fwd: [perl #120888] scope.c cause an unaligned access exception.
To: perlbug-followup [...] perl.org, perl5-porters [...] perl.org, Yves Orton <demerphq [...] gmail.com>, jkeen [...] verizon.net, comition [...] mac.com
Download (untitled) / with headers
text/plain 179.6k

Message body is not shown because it is too large.

From: "Naruaki.Etomi" <nullnilaki [...] gmail.com>
Subject: Fwd: [perl #120888] scope.c cause an unaligned access exception.
To: perlbug-followup [...] perl.org, perl5-porters [...] perl.org, Yves Orton <demerphq [...] gmail.com>, comition [...] mac.com
Date: Sun, 29 Dec 2013 14:21:50 +0900
Download (untitled) / with headers
text/plain 172.8k

Message body is not shown because it is too large.

Date: Mon, 30 Dec 2013 11:25:22 +0000
From: Dave Mitchell <davem [...] iabyn.com>
To: perl5-porters [...] perl.org
Subject: Re: [perl #120888] scope.c cause an unaligned access exception.
Download (untitled) / with headers
text/plain 910b
On Sat, Dec 28, 2013 at 05:05:33AM -0800, 江富功朗 wrote: Show quoted text
> Core was generated by `perl'. > Program terminated with signal 10, Bus error. > #0 0x00000001601795c8 in Perl_leave_scope (my_perl=0x160505000, > base=<optimized out>) at scope.c:1217 > 1217 *(I8*)ARG0_PTR = (I8)(uv >> 8);
I don't understand why this would cause an alignment error; it's casting a pointer to be a pointer to a signed char (1 byte), then writing to it. More or less by definition, writing a byte shouldn't give alignment errors. Can you show the output of the following commands please, run in the directory where you're trying to build 5.18.1: grep I8TYPE config.h grep I8SIZE config.h -- A major Starfleet emergency breaks out near the Enterprise, but fortunately some other ships in the area are able to deal with it to everyone's satisfaction. -- Things That Never Happen in "Star Trek" #13
Subject: Re: [perl #120888] scope.c cause an unaligned access exception.
To: perl5-porters [...] perl.org
From: Vincent Pit <perl [...] profvince.com>
Date: Mon, 30 Dec 2013 13:19:24 +0100
Download (untitled) / with headers
text/plain 860b
On 12/30/13 12:25, Dave Mitchell wrote: Show quoted text
> On Sat, Dec 28, 2013 at 05:05:33AM -0800, 江富功朗 wrote:
>> Core was generated by `perl'. >> Program terminated with signal 10, Bus error. >> #0 0x00000001601795c8 in Perl_leave_scope (my_perl=0x160505000, >> base=<optimized out>) at scope.c:1217 >> 1217 *(I8*)ARG0_PTR = (I8)(uv >> 8);
> I don't understand why this would cause an alignment error; it's casting a > pointer to be a pointer to a signed char (1 byte), then writing to it. > More or less by definition, writing a byte shouldn't give alignment > errors.
It can happen on alpha or ppc architectures if ARG0_PTR is not aligned on 4 or 8 bytes boundaries, like for this : int n; char *p = &n; char *q = p + 1; *q = 123; /* boom */ But I don't understand why ARG0_PTR wouldn't have such alignment here. Vincent
Subject: Re: [perl #120888] scope.c cause an unaligned access exception.
To: Vincent Pit <perl [...] profvince.com>
From: "Craig A. Berry" <craig.a.berry [...] gmail.com>
CC: "Perl5 Porters (E-mail)" <perl5-porters [...] perl.org>
Date: Mon, 30 Dec 2013 08:02:15 -0600
Download (untitled) / with headers
text/plain 1.3k
On Mon, Dec 30, 2013 at 6:19 AM, Vincent Pit <perl@profvince.com> wrote: Show quoted text
> On 12/30/13 12:25, Dave Mitchell wrote:
>> >> On Sat, Dec 28, 2013 at 05:05:33AM -0800, 江富功朗 wrote:
>>> >>> Core was generated by `perl'. >>> Program terminated with signal 10, Bus error. >>> #0 0x00000001601795c8 in Perl_leave_scope (my_perl=0x160505000, >>> base=<optimized out>) at scope.c:1217 >>> 1217 *(I8*)ARG0_PTR = (I8)(uv >> 8);
>> >> I don't understand why this would cause an alignment error; it's casting a >> pointer to be a pointer to a signed char (1 byte), then writing to it. >> More or less by definition, writing a byte shouldn't give alignment >> errors.
> > > It can happen on alpha or ppc architectures if ARG0_PTR is not aligned on 4 > or 8 bytes boundaries, like for this : > > int n; > char *p = &n; > char *q = p + 1; > *q = 123; /* boom */ > > But I don't understand why ARG0_PTR wouldn't have such alignment here.
Isn't it more likely it's the "(I8)(uv >> 8)" rather than anything to do with ARG0_PTR? I think the optimizer might decide to step over the first byte and grab the second one, i.e., why shift if the end result is going to be the same as pulling bits 8-15 directly out of a 64-bit value. But of course the compiler should know better than to do that if it's going to generate an unaligned access.
From: Dave Mitchell <davem [...] iabyn.com>
CC: perl5-porters [...] perl.org
Subject: Re: [perl #120888] scope.c cause an unaligned access exception.
To: Vincent Pit <perl [...] profvince.com>
Date: Mon, 30 Dec 2013 15:32:55 +0000
Download (untitled) / with headers
text/plain 1.1k
On Mon, Dec 30, 2013 at 01:19:24PM +0100, Vincent Pit wrote: Show quoted text
> On 12/30/13 12:25, Dave Mitchell wrote:
> >On Sat, Dec 28, 2013 at 05:05:33AM -0800, 江富功朗 wrote:
> >>Core was generated by `perl'. > >>Program terminated with signal 10, Bus error. > >>#0 0x00000001601795c8 in Perl_leave_scope (my_perl=0x160505000, > >>base=<optimized out>) at scope.c:1217 > >>1217 *(I8*)ARG0_PTR = (I8)(uv >> 8);
> >I don't understand why this would cause an alignment error; it's casting a > >pointer to be a pointer to a signed char (1 byte), then writing to it. > >More or less by definition, writing a byte shouldn't give alignment > >errors.
> > It can happen on alpha or ppc architectures if ARG0_PTR is not > aligned on 4 or 8 bytes boundaries, like for this : > > int n; > char *p = &n; > char *q = p + 1; > *q = 123; /* boom */
You seem to be implying that a char* pointer needs to be aligned on a 4/8 byte boundary. Unless I'm misunderstanding you, that makes no sense. I'd expect your code above to overwrite one of the bytes that make up the storage for the integer n. -- I before E. Except when it isn't.
Date: Mon, 30 Dec 2013 15:51:37 -0600
From: "Craig A. Berry" <craig.a.berry [...] gmail.com>
CC: Craig Berry via RT <perlbug-followup [...] perl.org>, "Perl5 Porters (E-mail)" <perl5-porters [...] perl.org>, Yves Orton <demerphq [...] gmail.com>, James E Keenan <jkeen [...] verizon.net>
Subject: Re: [perl #120888] scope.c cause an unaligned access exception.
To: 江富功朗 <nullnilaki [...] gmail.com>
Download (untitled) / with headers
text/plain 2.4k
On Sat, Dec 28, 2013 at 10:29 PM, 江富功朗 <nullnilaki@gmail.com> wrote: Show quoted text
> > I think this problem disadvantage isobviously the loss of performance > on alpha (and IA64? and amd64?). > > Please look at the > Intel 64 and IA-32 Architectures Software Developer’s Manual Combined > Volumes:1, 2A, 2B, 2C, 3A, 3B, and 3C > and read section 4.1.1 Alignment of Words, Doublewords, Quadwords, > and Double Quadwords.
I managed to find this at <http://flint.cs.yale.edu/cs422/doc/24547012.pdf> and the section you reference starts on page 72. It's talking about IA-32 and doesn't seem directly relevant. Yes, alignment faults are bad, worse on some architectures than others. But C programs must sometimes deal with data one byte at a time and the compiler should be generating instructions to produce aligned access in this case. Show quoted text
> ---------------------------------------- > $ perl -Mre=debug -e "/just|another|perl|hacker/" > pid 388 (perl): unaligned access: va=0x16050fcee pc=0x1601895c4 > ra=0x160189124 sp=0x1ffffd0f0 op=ldl > pid 388 (perl): unaligned access: va=0x16050fcee pc=0x1601895d0 > ra=0x160189124 sp=0x1ffffd0f0 op=stl
If "va" means virtual address, then 0x16050fcee is an even number but not a multiple of 4 or 8 and thus word (16-bit) aligned, but not longword (32-bit) or quadword (64-bit) aligned. I don't really know Alpha assembler but I'm pretty sure stl and ldl store and load longwords. So we have longword instructions operating on a word-aligned address; that does sound like an alignment fault. The Alpha assembly tutorial at <http://www.cs.cmu.edu/afs/cs/academic/class/15213-f98/doc/alpha-guide.pdf>, in sections 2.6 and 2.6.1 (starting on page 7) seems to indicate that byte-level operations can be done entirely using quadword-aligned memory accesses. So I think the real question is why isn't gcc doing that for the relevant line in scope.c? For the original poster: Can you post verbose compiler version output? Can you report your Alpha system or processor model? Does turning off optimizations with -Doptimize=-O0 make the problem go away? Does adding -mcpu=XXXX to your compiler flags make any difference, where XXXX matches the exact version of Alpha cpu your system has (options at <http://gcc.gnu.org/onlinedocs/gcc/DEC-Alpha-Options.html>)? Do you know enough C to write a small C program that reproduces the alignment error? It should just need that single line from scope.c and enough declarations to get things set up.
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 1.1k
On Mon Dec 30 13:51:54 2013, craig.a.berry@gmail.com wrote: Show quoted text
> On Sat, Dec 28, 2013 at 10:29 PM, 江富功朗 <nullnilaki@gmail.com> wrote: >
> > > > I think this problem disadvantage isobviously the loss of performance > > on alpha (and IA64? and amd64?). > > > > Please look at the > > Intel 64 and IA-32 Architectures Software Developer’s Manual Combined > > Volumes:1, 2A, 2B, 2C, 3A, 3B, and 3C > > and read section 4.1.1 Alignment of Words, Doublewords, Quadwords, > > and Double Quadwords.
> > I managed to find this at > <http://flint.cs.yale.edu/cs422/doc/24547012.pdf> and the section you > reference starts on page 72. It's talking about IA-32 and doesn't > seem directly relevant. Yes, alignment faults are bad, worse on some > architectures than others. But C programs must sometimes deal with > data one byte at a time and the compiler should be generating > instructions to produce aligned access in this case.
http://books.google.com/books?id=GumAeql5KPkC&lpg=PP1&dq=intitle%3Aalpha%20assembler%20risc&pg=SA4-PA6#v=onepage&q&f=false If I read that correctly, "natural alignment" is the requirement, so by byte access should unalign fault. -- bulk88 ~ bulk88 at hotmail.com
Date: Mon, 30 Dec 2013 17:03:34 -0800
Subject: Re: [perl #120888] scope.c cause an unaligned access exception.
To: perl5-porters [...] perl.org
From: Greg Lindahl <greg [...] blekko.com>
Download (untitled) / with headers
text/plain 903b
On Mon, Dec 30, 2013 at 03:51:37PM -0600, Craig A. Berry wrote: Show quoted text
> The Alpha assembly tutorial at > <http://www.cs.cmu.edu/afs/cs/academic/class/15213-f98/doc/alpha-guide.pdf>, > in sections 2.6 and 2.6.1 (starting on page 7) seems to indicate that > byte-level operations can be done entirely using quadword-aligned > memory accesses.
That's because Alpha didn't originally have byte load/stores... they were faked with word loads and masks, etc. Real byte loads/stores were added later, but I'm not surprised that the manuals still contain lots of artifacts from the pre-byte days. Alphas under Linux have a kernel software fixup for unaligned loads/stores that would make the program work but with potentially bad perf; but apparently netbsd doesn't do that. The things you ask for are the right ones to diagnose. I agree that it seems that ARG0_PTR is not arriving with good alignment. -- greg
Date: Mon, 30 Dec 2013 21:39:09 -0600
CC: "Perl5 Porters (E-mail)" <perl5-porters [...] perl.org>
From: "Craig A. Berry" <craig.a.berry [...] gmail.com>
To: Greg Lindahl <greg [...] blekko.com>
Subject: Re: [perl #120888] scope.c cause an unaligned access exception.
Download (untitled) / with headers
text/plain 1.3k
On Mon, Dec 30, 2013 at 7:03 PM, Greg Lindahl <greg@blekko.com> wrote: Show quoted text
> On Mon, Dec 30, 2013 at 03:51:37PM -0600, Craig A. Berry wrote: >
>> The Alpha assembly tutorial at >> <http://www.cs.cmu.edu/afs/cs/academic/class/15213-f98/doc/alpha-guide.pdf>, >> in sections 2.6 and 2.6.1 (starting on page 7) seems to indicate that >> byte-level operations can be done entirely using quadword-aligned >> memory accesses.
> > That's because Alpha didn't originally have byte load/stores... they > were faked with word loads and masks, etc. Real byte loads/stores were > added later, but I'm not surprised that the manuals still contain lots > of artifacts from the pre-byte days.
Right. That's why I want to see detailed compiler version info and/or get a build attempted targeting the specific Alpha architecture of the machine where we're seeing the alignment faults. Show quoted text
> Alphas under Linux have a kernel software fixup for unaligned > loads/stores that would make the program work but with potentially > bad perf; but apparently netbsd doesn't do that.
It looks like netbsd by default does the fix-ups but also warns. You can independently enable or disable the fix-ups and the warnings: <http://www.netbsd.org/ports/alpha/faq.html#unaligned>. Show quoted text
> The things you ask for are the right ones to diagnose. I agree that it > seems that ARG0_PTR is not arriving with good alignment. > > -- greg >
CC: perl5-porters [...] perl.org
From: Dave Mitchell <davem [...] iabyn.com>
To: Greg Lindahl <greg [...] blekko.com>
Subject: Re: [perl #120888] scope.c cause an unaligned access exception.
Date: Tue, 31 Dec 2013 12:14:45 +0000
Download (untitled) / with headers
text/plain 1.4k
On Mon, Dec 30, 2013 at 05:03:34PM -0800, Greg Lindahl wrote: Show quoted text
> On Mon, Dec 30, 2013 at 03:51:37PM -0600, Craig A. Berry wrote: >
> > The Alpha assembly tutorial at > > <http://www.cs.cmu.edu/afs/cs/academic/class/15213-f98/doc/alpha-guide.pdf>, > > in sections 2.6 and 2.6.1 (starting on page 7) seems to indicate that > > byte-level operations can be done entirely using quadword-aligned > > memory accesses.
> > That's because Alpha didn't originally have byte load/stores... they > were faked with word loads and masks, etc. Real byte loads/stores were > added later, but I'm not surprised that the manuals still contain lots > of artifacts from the pre-byte days. > > Alphas under Linux have a kernel software fixup for unaligned > loads/stores that would make the program work but with potentially > bad perf; but apparently netbsd doesn't do that. > > The things you ask for are the right ones to diagnose. I agree that it > seems that ARG0_PTR is not arriving with good alignment.
I still don''t follow this. ARG0_PTR is being used to read a single byte. This should never cause an alignment error; even if the underlying h/w doesn't support byte reads, the compiler should convert something like char c = *((char *)p) into something like int i = *((int *)i(p & ~7); char c = shift_and_mask(i); -- Little fly, thy summer's play my thoughtless hand has terminated with extreme prejudice. (with apologies to William Blake)
Date: Tue, 31 Dec 2013 07:44:56 -0600
CC: Greg Lindahl <greg [...] blekko.com>, "Perl5 Porters (E-mail)" <perl5-porters [...] perl.org>
From: "Craig A. Berry" <craig.a.berry [...] gmail.com>
To: Dave Mitchell <davem [...] iabyn.com>
Subject: Re: [perl #120888] scope.c cause an unaligned access exception.
Download (untitled) / with headers
text/plain 1.7k
On Tue, Dec 31, 2013 at 6:14 AM, Dave Mitchell <davem@iabyn.com> wrote: Show quoted text
> On Mon, Dec 30, 2013 at 05:03:34PM -0800, Greg Lindahl wrote:
>> On Mon, Dec 30, 2013 at 03:51:37PM -0600, Craig A. Berry wrote:
Show quoted text
>> The things you ask for are the right ones to diagnose. I agree that it >> seems that ARG0_PTR is not arriving with good alignment.
> > I still don''t follow this. ARG0_PTR is being used to read a single byte.
I think mentioning ARG0_PTR (the target of the assignment) is a red herring. It translates to arg0.any_ptr, a union member, which is by definition at the beginning of a union. If the compiler can't put unions and structs on naturally aligned boundaries, all bets are off and there would be lots more alignment faults anywhere and everywhere. I think the source of the assignment is more likely where the trouble is. Show quoted text
> This should never cause an alignment error; even if the underlying h/w > doesn't support byte reads, the compiler should convert something....
Exactly, but for some reason it doesn't look like this compiler is doing what it should in this one case. I really don't think Perl is at fault, but it's hard to say for sure without pinning down a bit further what exactly is going wrong. To anyone with gcc/NetBSD/Alpha handy, please try running the following and let us know if you get an alignment fault: $ cat > checkalign.c #include <stdio.h> typedef union any ANY; union any { void* any_ptr; unsigned int any_int; unsigned char any_char; }; int main() { ANY arg0; int tmp = 0xdeadbeef; arg0.any_ptr = &tmp; unsigned long long int uv = 0x4200; *(char*)arg0.any_ptr = (char)(uv >> 8); printf("tmp is 0x%x\n", tmp); } <CTRL-D> $ cc -O2 -o checkalign checkalign.c $ ./checkalign tmp is 0xdeadbe42
Date: Wed, 1 Jan 2014 06:50:28 +0900
CC: perl5-porters [...] perl.org, craig.a.berry [...] gmail.com, davem [...] iabyn.com, greg [...] blekko.com, bulk88 [...] hotmail.com, perl [...] profvince.com, jkeen [...] verizon.net, Yves Orton <demerphq [...] gmail.com>
From: "Naruaki.Etomi" <nullnilaki [...] gmail.com>
To: perlbug-followup [...] perl.org
Subject: [perl #120888] scope.c cause an unaligned access exception.
Download (untitled) / with headers
text/plain 1.6k
Thank you for your mail! This problem was caused by compiler's bug. -ftree-ter option makes wrong binary. I'm sorry to have caused you trouble. Please close this topic. ---------------------------------------- $ perl -Mre=debug -e "/just|another|perl|hacker/" Compiling REx "just|another|perl|hacker" Final program: 1: TRIEC-EXACT[ahjp] (15) <just> <another> <perl> <hacker> 15: END (0) stclass AHOCORASICKC-EXACT[ahjp] minlen 4 Freeing REx: "just|another|perl|hacker" ---------------------------------------- # gcc -v Using built-in specs. COLLECT_GCC=gcc Target: alpha--netbsd Configured with: /usr/src2/tools/gcc/../../external/gpl3/gcc/dist/configure --target=alpha--netbsd --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb2 20111202' --enable-__cxa_atexit --with-mpc=/var/obj/mknative/alpha/usr/src2/destdir.alpha/usr --with-mpfr=/var/obj/mknative/alpha/usr/src2/destdir.alpha/usr --with-gmp=/var/obj/mknative/alpha/usr/src2/destdir.alpha/usr --enable-tls --disable-multilib --disable-symvers --disable-libstdcxx-pch --build=x86_64-unknown-netbsd5.99.56 --host=alpha--netbsd Thread model: posix gcc version 4.5.3 (NetBSD nb2 20110806) ---------------------------------------- AlphaStation DS15, 1000MHz 8192 byte page size, 1 processor. total memory = 512 MB (2880 KB reserved for PROM, 509 MB used by NetBSD) avail memory = 490 MB timecounter: Timecounters tick every 0.976 msec mainbus0 (root) cpu0 at mainbus0: ID 0 (primary), 21264C-6 cpu0: Architecture extensions: 0x1307<PAT,MVI,CIX,FIX,BWX> ---------------------------------------- That's very nice of you! -- Naruaki Etomi / nullnilaki@gmail.com
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 285b
On Tue Dec 31 14:53:53 2013, nullnilaki@gmail.com wrote: Show quoted text
> Thank you for your mail! > > This problem was caused by compiler's bug. > -ftree-ter option makes wrong binary. > I'm sorry to have caused you trouble. > Please close this topic. >
Closed per request from original poster.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org