New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sv_upgrade() loses 64-bit alignment, causing SIGBUS on sparc #9567
Comments
From @ntyniThis is a bug report for perl from Niko Tyni <ntyni@debian.org> As seen in <http://bugs.debian.org/505415>, calling sv_chop() or otherwise This was uncovered by the JSON-XS-2.23 test suite failing for us on On 5.10.0, calling sv_chop() will upgrade the SV into an SVt_PVIV due Calling the SvGROW() macro afterwards will cast sv->sv_any to an XPV I'm attaching a test program that mimics what JSON-XS does when compiled This particular failure mode has been fixed in bleadperl with change However, it seems to me that this is a more general problem that should The same test program, when compiled with -O2 but without -DUSE_CHOP Note that using a debugging perl build (-DDEBUGGING) seems to defeat the crash. Details for the bleadperl SIGBUS: Program received signal SIGBUS, Bus error. The preprocessor output for the above SvGROW() invocation is (((XPV*) (sv)->sv_any)->xpv_len < (((XPV*) (sv)->sv_any)->xpv_cur + 1) ? Perl_sv_grow(my_perl, sv,((XPV*) (sv)->sv_any)->xpv_cur + 1) : ((sv)->sv_u.svu_pv)); The instruction that causes the bus error is a double-word load (ldd) 0x00010708 <doit+56>: ld [ %i1 ], %g1 Quoting Julien Cristau in the Debian bug:
Flags: Site configuration information for perl 5.11.0: Configured by niko at Sat Nov 15 18:40:57 UTC 2008. Summary of my perl5 (revision 5 version 11 subversion 0) configuration: Locally applied patches: @INC for perl 5.11.0: Environment for perl 5.11.0: |
From @ntyni#include <EXTERN.h>
#include <perl.h>
static PerlInterpreter *my_perl;
SV *sv;
void doit(void) {
sv = newSVpv("foo", 3);
#ifdef USE_CHOP
sv_chop(sv, SvPV_nolen(sv) + 1);
#else
SvUPGRADE(sv, SVt_PVIV);
#endif
SvGROW (sv, SvCUR (sv) + 1);
}
int main(int argc, char **argv, char **env)
{
int i;
my_perl = perl_alloc();
for (i=0; i<10; i++) {
printf("try %d\n", i);
doit();
}
}
|
From @nwc10On Sun, Nov 16, 2008 at 04:16:14AM -0800, Niko Tyni wrote:
Yes, it's a more general problem.
What is __alignof__(XPVIV) and sizeof(XPVIV) on the same system?
I see that -fno-strict-aliasing is on. That might prove relevant in my reply Nicholas Clark |
The RT System itself - Status changed from 'new' to 'open' |
From @ntyniOn Sun, Nov 16, 2008 at 05:15:36PM +0000, Nicholas Clark wrote:
8 and 24.
I didn't explicitly ask for it, so it would seem to be on by default. |
From @nwc10On Sun, Nov 16, 2008 at 08:17:17PM +0200, Niko Tyni wrote:
whereas __alignof__(xpv_allocated) and sizeof(xpv_allocated) are 8 and 4, If so, that would explain a lot, and it's my fault.
It is Perl's default for gcc. I think it may not be relevant now. Nicholas Clark |
From @ntyniOn Mon, Nov 17, 2008 at 03:44:18PM +0000, Nicholas Clark wrote:
The other way around, otherwise right. XPV: alignof: 8 sizeof: 16
Looking forward to the explanation :) Thanks for your work, |
From au@hcsd.deHi, I just ran into the same bug with Perl 5.8.8 compiled with Sun's Regards, Stephan Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Characteristics of this binary (from libperl): |
From [Unknown Contact. See original ticket]Hi, I just ran into the same bug with Perl 5.8.8 compiled with Sun's Regards, Stephan Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Characteristics of this binary (from libperl): |
From au@hcsd.deJust to provide the core file details... # dbx -f /opt/mssperl5/bin/perl core |
From [Unknown Contact. See original ticket]Just to provide the core file details... # dbx -f /opt/mssperl5/bin/perl core |
From au@hcsd.deQuoting myself...
I have fixed the SIGBUS by upgrading to Perl 5.8.9 and using a less Regards, Stephan |
From @jimcXPV and XPVIV are both special bodies, they use the ghost-fields trick, I dont have a 64 bit machine, so I can only speculate, /* 8 bytes on most ILP32 with IEEE doubles */ /* 12 */ |
From @nwc10On Mon, Nov 17, 2008 at 08:52:28PM +0200, Niko Tyni wrote:
Sorry for the delay. Does change 69ba284 I don't have access to sparc Debian, but I do have limited acces to sparc bash-2.05$ ./perl -Ilib align.pl >align.c && gcc -Wall -o align align.c && ./align XPVIV 24 8 XPVAV 32 8 XPVHV 32 8 XPVCV 64 8 XPVFM 64 8 XPVIO 88 8 regexp 96 8 bash-2.05$ sizeof() ^ ^ __alignof__() So I think the new way preserves the alignment constraint. If I've got this right, I'll explain further if necessary. I'm not committing Nicholas Clark #!perl -w print <<'EOH'; int main() { my %first = ( my @types = qw(XPV XPVIV XPVAV XPVHV XPVCV XPVFM); foreach my $raw (@types) { print <<'EOH'; __END__ |
From @ntyniOn Fri, Jul 17, 2009 at 08:44:40PM +0100, Nicholas Clark wrote:
Yes, I can confirm it fixes it all for me on both blead and maint-5.10,
This is the output on maint-5.10 here: XPV 16 8 XPVIV 24 8 XPVAV 32 8 XPVHV 32 8 XPVCV 64 8 XPVFM 72 8 Many thanks for your work! Much appreciated. |
From @nwc10Resolved and released. I want to close the RT ticket now, but I still Nicholas Clark |
@nwc10 - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#60574 (status was 'resolved')
Searchable as RT60574$
The text was updated successfully, but these errors were encountered: