Re: Bus error in formatting.c NUM_numpart_to_char (9.4.12, 9.6.3, sparc)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Tom Turelinckx" <tom(at)turelinckx(dot)be>
Cc: pgsql-bugs(at)postgreSQL(dot)org
Subject: Re: Bus error in formatting.c NUM_numpart_to_char (9.4.12, 9.6.3, sparc)
Date: 2017-06-22 21:09:29
Message-ID: 15142.1498165769@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Tom Turelinckx" <tom(at)turelinckx(dot)be> writes:
>> Maybe you could extract those bits too? Or if you prefer, just send me the whole .s files off-list.

> Whole .s files attached.

Thanks. The short of it seems to be that this is a compiler bug.
In the "original" code, the out-of-line segment at .LL726 is

.loc 1 4415 0
ldsb [%g4], %g4
.LL726:
cmp %g4, 48
bne,pt %icc, .LL715
andcc %g2, 64, %g0
ld [%g3+4], %g4
cmp %g4, 0
be,pt %icc, .LL715
andcc %g2, 64, %g0
ld [%fp-24], %g4
cmp %g4, 0
be,pn %icc, .LL727
add %l7, -2, %g3 <--- trashes %g3
ldsb [%g4], %g4
cmp %g4, 46
bne,a,pt %icc, .LL748
xor %l7, 6, %g2
.loc 1 4417 0
ba,pt %xcc, .LL715 <--- returns to .LL715 which needs %g3
andcc %g2, 64, %g0

The corresponding part in the "patched" code is

.LL693:
.LLBE547:
.LLBE578:
.LLBB579:
.LLBB556:
.loc 1 4415 0
cmp %o7, 48
bne,pt %icc, .LL712
andcc %g3, 64, %g0
ld [%g4+4], %o7
cmp %o7, 0
be,pt %icc, .LL712
andcc %g3, 64, %g0
ld [%fp-24], %o7
cmp %o7, 0
be,a,pn %icc, .LL722
add %g1, -2, %g4 <--- store to %g4 is annulled if no branch
ldsb [%o7], %o7
cmp %o7, 46
bne,a,pt %icc, .LL722
add %g1, -2, %g4 <--- store to %g4 is annulled if no branch
.loc 1 4417 0
ba,pt %xcc, .LL712 <--- returns to .LL712 which needs %g4
andcc %g3, 64, %g0

In short, the compiler is trying to hoist the first instruction for line
4456 into the delay slot of that branch to .LL727, and it's getting it
wrong. This would've been fine if the compiler had remembered to put the
"a" (annul) flag on the branch instruction, but it forgot.

I think you need to file a bug with the gcc maintainers. No idea if
there's anything you can give them that's shorter than this full
file, but maybe they won't care.

As a short-term workaround, reducing the -O level might help.
Or perhaps there's a different gcc version you could use?

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Amit Langote 2017-06-23 00:35:55 Re: Beta 10 parser error for CREATE STATISTICS IF NOT EXISTS
Previous Message Tom Lane 2017-06-22 18:51:44 Re: Bus error in formatting.c NUM_numpart_to_char (9.4.12, 9.6.3, sparc)