develooper Front page | perl.perl5.porters | Postings from May 2013

Re: [perl #118055] miniperl fails with SIGBUS on sparc(usethreads+use64bitint)

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
May 27, 2013 14:20
Subject:
Re: [perl #118055] miniperl fails with SIGBUS on sparc(usethreads+use64bitint)
Message ID:
20130527142040.GF3729@plum.flirble.org
On Sat, May 25, 2013 at 11:26:40AM -0400, Andrew Dougherty wrote:
> On Sat, 25 May 2013, Nicholas Clark wrote:
> 
> > On Sat, May 25, 2013 at 10:57:47AM -0400, Andy Dougherty wrote:
> > 
> > > It's just taking a long time to actually finish.  I'll report back when it 
> > > does.
> > > 
> > > Meanwhile, what would you think about tweaking it like this:
> > > 
> > > diff --git a/op.c b/op.c
> > > index 792e8d6..fd69c56 100644
> > > --- a/op.c
> > > +++ b/op.c
> > > @@ -175,7 +175,7 @@ Perl_Slab_Alloc(pTHX_ size_t sz)
> > >       || (CvSTART(PL_compcv) && !CvSLABBED(PL_compcv)))
> > >  	return PerlMemShared_calloc(1, sz);
> > >  
> > > -#if defined(USE_ITHREADS) && IVSIZE > U32SIZE
> > > +#if defined(USE_ITHREADS) && IVSIZE > U32SIZE && !defined(__x86_64__)
> > >      /* Work around a goof with alignment on our part. For sparc32 (and
> > >         possibly other architectures), if built with -Duse64bitint, the IV
> > >         op_pmoffset in struct pmop should be 8 byte aligned, but the slab
> > 
> > Good point. But I think that that's more restrictive than it needs to be.
> > I think that this would be valid:
> > 
> > #if defined(USE_ITHREADS) && IVSIZE > U32SIZE && IVSIZE > PTRSIZE
> 
> Yes, that would catch the relevant SPARC case (-Duse64bitint on an 
> otherwise 32-bit build).

I pushed this tweak as smoke-me/nicholas/rt-118055-1

commit f61a27cade956988ec6c5ff53b8aff3492ca5839
Author: Nicholas Clark <nick@ccl4.org>
Date:   Sun May 26 08:50:17 2013 +0200

    Improved struct pmop alignment fix - avoid the slow path on 64 bit systems.
    
    Commit c2a50ddb1bed6576 works round an alignment bug in the slab allocator
    for 32 bit systems built with 64 bit IVs. However, the C pre-processor logic
    meant that the test path was enabled on true 64 bit systems. It's not needed
    there, so improve the logic so that it isn't compiled for platforms where
    pointers are 64 bit.

diff --git a/op.c b/op.c
index 792e8d6..c5dbb68 100644
--- a/op.c
+++ b/op.c
@@ -175,7 +175,7 @@ Perl_Slab_Alloc(pTHX_ size_t sz)
      || (CvSTART(PL_compcv) && !CvSLABBED(PL_compcv)))
 	return PerlMemShared_calloc(1, sz);
 
-#if defined(USE_ITHREADS) && IVSIZE > U32SIZE
+#if defined(USE_ITHREADS) && IVSIZE > U32SIZE && IVSIZE > PTRSIZE
     /* Work around a goof with alignment on our part. For sparc32 (and
        possibly other architectures), if built with -Duse64bitint, the IV
        op_pmoffset in struct pmop should be 8 byte aligned, but the slab

> Correct.  With current blead on Linux x86_64, every op allocation still 
> tests
> 
>     if(sz == sizeof(struct pmop) 
> 
> and even though the test is always false for that program, the cummulative 
> cost of doing the test is (just barely) measurable.

With the change as shown, that code is no longer compiled on any platform with
64 bit pointers.

I tested 4 configurations on Sparc, Mips and Arm Linux, and all were (still)
happy.

Nicholas Clark

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About