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 10:21:58 -0400
Message-ID: <24675.1498141318@sss.pgh.pa.us> (raw)
In-Reply-To: <000101d2eb5e$60a7ab60$21f70220$@turelinckx.be>
References: <006b01d2eaa2$d4317be0$7c9473a0$@turelinckx.be>
	<2069.1498062248@sss.pgh.pa.us>
	<000101d2eb5e$60a7ab60$21f70220$@turelinckx.be>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

"Tom Turelinckx" <tom@turelinckx.be> writes:
> But I need more information / pointers to documentation on how to find and provide the information you need, as I have no experience with looking at assembly code.

The way to get an assembly code file is to substitute -S for -c in the
compile command, and also remove any "-o file" option.  So on my machine,
in an already built PG tree, I check what switches we're using:

$ cd src/backend/utils/adt
$ rm formatting.o
$ make formatting.o
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -O2 -I../../../../src/include -D_GNU_SOURCE    -c -o formatting.o formatting.c

Now I copy-and-paste all the switches except -c and -o:

$ gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -O2 -I../../../../src/include -D_GNU_SOURCE -S formatting.c

Note it's important that -g be one of the switches, else you don't get
line number annotations in the assembly.

Now I have a formatting.s file with contents like

.L275:
.LBE196:
.LBB197:
.LBB193:
	.loc 1 2320 0
	leal	-1(%rcx), %edi
	cmpl	$1, %edi
	jbe	.L278
	.loc 1 2322 0
	cmpl	$3, %ecx
	.p2align 4,,2
	je	.L279
.LVL216:
.L246:
	.loc 1 2325 0
	movq	(%rdx), %rax
	testq	%rax, %rax
	je	.L244
	.loc 1 2331 0
	leaq	1(%r14), %rdi
	movq	%r14, 48(%rsp)
	movq	%rbx, 64(%rsp)
	.loc 1 2325 0
	xorl	%r10d, %r10d
	.loc 1 2331 0
	movq	%rdx, %rbx

The important part of this for your purposes is the ".loc" annotations,
which indicate the source line number the following code was generated
from.  Notice that's not unusual for the compiler to rearrange code so
that instructions from different lines are interspersed --- here we
can see that lines 2325 and 2331 got mingled together.  So there might
not be only one .loc annotation for the line where the crash is being
reported.  Anyway, find those annotation(s) and send us all the text
for that area and maybe a few dozen lines on either side.

			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: <24675.1498141318@sss.pgh.pa.us>
Permalink:  ../24675.1498141318@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/24675.1498141318@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: <24675.1498141318@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>

* 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