pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tom Turelinckx <tom@turelinckx.be>
Cc: pgsql-bugs@postgreSQL.org
Subject: Re: Bus error in formatting.c NUM_numpart_to_char (9.4.12, 9.6.3, sparc)
Date: Thu, 22 Jun 2017 17:09:29 -0400
Message-ID: <15142.1498165769@sss.pgh.pa.us> (raw)
In-Reply-To: <002201d2eb94$c8bc8190$5a3584b0$@turelinckx.be>
References: <006b01d2eaa2$d4317be0$7c9473a0$@turelinckx.be>
	<2069.1498062248@sss.pgh.pa.us>
	<000101d2eb5e$60a7ab60$21f70220$@turelinckx.be>
	<24675.1498141318@sss.pgh.pa.us>
	<001501d2eb78$e52a8e60$af7fab20$@turelinckx.be>
	<9547.1498157504@sss.pgh.pa.us>
	<002201d2eb94$c8bc8190$5a3584b0$@turelinckx.be>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

"Tom Turelinckx" <tom@turelinckx.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


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (14+ messages)  latest in thread

Message-ID: <15142.1498165769@sss.pgh.pa.us>
Permalink:  ../15142.1498165769@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/15142.1498165769@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, tom@turelinckx.be
  Subject: Re: Bus error in formatting.c NUM_numpart_to_char (9.4.12, 9.6.3, sparc)
  In-Reply-To: <15142.1498165769@sss.pgh.pa.us>
  References: <006b01d2eaa2$d4317be0$7c9473a0$@turelinckx.be> <2069.1498062248@sss.pgh.pa.us> <000101d2eb5e$60a7ab60$21f70220$@turelinckx.be> <24675.1498141318@sss.pgh.pa.us> <001501d2eb78$e52a8e60$af7fab20$@turelinckx.be> <9547.1498157504@sss.pgh.pa.us> <002201d2eb94$c8bc8190$5a3584b0$@turelinckx.be> <15142.1498165769@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox