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 14:21:58
Message-ID: 24675.1498141318@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:
> 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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Turelinckx 2017-06-22 16:59:20 Re: Bus error in formatting.c NUM_numpart_to_char (9.4.12, 9.6.3, sparc)
Previous Message Tom Turelinckx 2017-06-22 13:49:31 Re: Bus error in formatting.c NUM_numpart_to_char (9.4.12, 9.6.3, sparc)