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 22, 2013 20:25
Subject:
Re: [perl #118055] miniperl fails with SIGBUS on sparc(usethreads+use64bitint)
Message ID:
20130522202519.GM3729@plum.flirble.org
On Wed, May 22, 2013 at 10:39:53PM +0300, Niko Tyni wrote:
> On Wed, May 22, 2013 at 12:33:28PM +0100, Nicholas Clark wrote:

> > I hope to have something sooner than that.

I had an insight on the tram. All sorts of complex hacks are complex...

> Thanks for looking at this. I'm happy to test anything you come up with. 

Try this. It's against blead. The comment in the diff hunk will conflict
against v5.18.0:

diff --git a/op.c b/op.c
index 96a06b1..341b087 100644
--- a/op.c
+++ b/op.c
@@ -175,6 +175,19 @@ Perl_Slab_Alloc(pTHX_ size_t sz)
      || (CvSTART(PL_compcv) && !CvSLABBED(PL_compcv)))
 	return PerlMemShared_calloc(1, sz);
 
+#if defined(USE_ITHREADS) && IVSIZE > U32SIZE
+    /* 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
+       allocator is only providing 4 byte alignment. The real fix is to change
+       the IV to a type the same size as a pointer, such as size_t, but we
+       can't do that without breaking the ABI, which is a no-no in a maint
+       release. So instead, simply allocate struct pmop directly, which will be
+       suitably aligned:  */
+    if (sz == sizeof(struct pmop))
+	return PerlMemShared_calloc(1, sz);
+#endif
+
     /* While the subroutine is under construction, the slabs are accessed via
        CvSTART(), to avoid needing to expand PVCV by one pointer for something
        unneeded at runtime. Once a subroutine is constructed, the slabs are

Not massively tested, but does get the (sadly soon to be decommisioned)
GCC compiler farm Sparc machine well past miniperl, and still chugging.

Would be nice to test this with & without -Duse64bitint on as many
architectures as practical. (I can get to x86_64, x86, sparc and mips, but
not tonight)

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