2.6-2 FTBFS on sparc (bus error in test cases)

Bug #534459 reported by StefanPotyra
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc-4.4 (Ubuntu)
Won't Fix
High
Kees Cook
patch (Debian)
Fix Released
Unknown
patch (Ubuntu)
Fix Released
High
Matthias Klose

Bug Description

Binary package hint: patch

excerpt from the buildlog (http://launchpadlibrarian.net/36793543/buildlog_ubuntu-lucid-sparc.patch_2.6-2_FAILEDTOBUILD.txt.gz)

--- expected
+++ got
@@ -1,10 +1,6 @@
-Hunk #1 NOT MERGED at 3-7.
+./tests/test-lib.sh: line 48: 14961 Bus error $PATCH "$@"
 1
 a
-<<<<<<<
 c
-=======
-b
->>>>>>>
 4
-Status: 1
+Status: 138
[193] x 6 3c3b 4c4b -- 3c3c 4c4c -- ok
[209] x 4 2cb 3ca -- 2cc 3ca -- FAILED
--- expected
+++ got
@@ -1,10 +1,6 @@
-Hunk #1 NOT MERGED at 2-6.
+./tests/test-lib.sh: line 48: 14993 Bus error $PATCH "$@"
[..]

just tested locally on a sparc box, problem still present, so a give-back won't suffice.

Cheers,
     Stefan.

Related branches

StefanPotyra (sistpoty)
Changed in patch (Ubuntu):
status: New → Confirmed
tags: added: kernel-series-unknown
tags: removed: kernel-series-unknown
Revision history for this message
StefanPotyra (sistpoty) wrote :

backtrace of on bus error (recreated the test-case by hand and ran within gdb):

Starting program: /tmp/patch/patch-2.6/src/patch -f --merge c < ab.diff
patching file c

Program received signal SIGBUS, Bus error.
0x00016cb4 in bestmatch (xoff=-7, xlim=5, yoff=-26610410486401528, ylim=8, min=1, max=2, py=0xffa177a0) at src/bestmatch.h:153
153 *py = ymax;
(gdb) bt
#0 0x00016cb4 in bestmatch (xoff=-7, xlim=5, yoff=-26610410486401528, ylim=8, min=1, max=2, py=0xffa177a0) at src/bestmatch.h:153
#1 0x00018568 in locate_merge (hunk=1, outstate=<value optimized out>, where=5, somefailed=<value optimized out>) at src/merge.c:105
#2 merge_hunk (hunk=1, outstate=<value optimized out>, where=5, somefailed=<value optimized out>) at src/merge.c:229
#3 0x0001ebb0 in main (argc=<value optimized out>, argv=<value optimized out>) at src/patch.c:289

Revision history for this message
StefanPotyra (sistpoty) wrote :

hm, something is really strange here:

info registers
(gdb) info registers
g0 0x0 0
g1 0x0 0
g2 0xffffffff -1
g3 0xffffffff -1
g4 0x0 0
g5 0x38 56
g6 0xfeffffff -16777217
g7 0xf7f05270 -135245200
o0 0x0 0
o1 0x2 2
o2 0xffffffff -1
o3 0xffffffff -1
o4 0x2 2
o5 0xffd8f648 -2558392
sp 0xffd8f5a0 0xffd8f5a0
o7 0x16ce4 93412
l0 0x0 0
l1 0x1 1
l2 0x0 0
l3 0x8 8
l4 0xffffffff -1
l5 0xfffffff7 -9
l6 0x0 0
l7 0x8 8
i0 0xffffffff -1
i1 0xfffffff9 -7
i2 0x0 0
i3 0x5 5
i4 0xffd8f5f8 -2558472
i5 0xffd8f608 -2558456
fp 0xffd8f690 0xffd8f690
i7 0x18560 99680
y 0x0 0
psr 0xff800087 [ #0 #1 #2 S #23 #24 #25 #26 #27 #28 #29 #30 #31 ]
wim 0x0 0
tbr 0x0 0
pc 0x16cb4 0x16cb4 <bestmatch+948>
npc 0x16cb8 0x16cb8 <bestmatch+952>
fsr 0x0 [ ]
csr 0x0 0

corresponding code (in parts, bus error at last instruction):
0x00016c9c <bestmatch+924>: ld [ %fp + -44 ], %o4
0x00016ca0 <bestmatch+928>: ld [ %fp + -84 ], %g3
0x00016ca4 <bestmatch+932>: cmp %g3, 0
0x00016ca8 <bestmatch+936>: be,pn %icc, 0x16cb8 <bestmatch+952>
0x00016cac <bestmatch+940>: nop
0x00016cb0 <bestmatch+944>: ldd [ %fp + -48 ], %o2
0x00016cb4 <bestmatch+948>: std %o2, [ %g3 ]

Revision history for this message
StefanPotyra (sistpoty) wrote :

hm, I've just tried a build with disabling stack protector, there the test cases work. Maybe that's related, but maybe it isn't.

Revision history for this message
Kees Cook (kees) wrote :

bus error implies a misaligned memory access? It's certainly possible the stack protector could be doing that -- sparc is less well tested with it. If we could get a minimal reproducer, we should be able to raise it with upstream gcc.

Revision history for this message
StefanPotyra (sistpoty) wrote :

hm, the more I look at the source in bestmatch.h, I think that this is not a gcc related problem, but rather an out of bounds problem in bestmatch.h (might be caused by yoff being very far off). I'll investigate further.

Revision history for this message
StefanPotyra (sistpoty) wrote :

patch test-case that fails when called with
patch -f --merge somefile < ab.diff

Revision history for this message
StefanPotyra (sistpoty) wrote :
Revision history for this message
StefanPotyra (sistpoty) wrote :

yes, stack-protector did its job fine on sparc, it's indeed an out of bounds access.

Revision history for this message
StefanPotyra (sistpoty) wrote :

*pfft*, I'm going in circles. the safety assertions from me are completely wrong, since fd points to the middle of V. Hence it's not an out-of-bounds access after all, and I'm back at the beginning with debugging.

Changed in patch (Debian):
status: Unknown → Fix Released
Revision history for this message
Matthias Klose (doko) wrote :

causes build failure in fpc on sparc. see bug #2253

Changed in patch (Ubuntu):
importance: Undecided → High
milestone: none → ubuntu-10.04-beta-2
status: Confirmed → Fix Committed
Changed in gcc-4.4 (Ubuntu):
assignee: nobody → Kees Cook (kees)
importance: Undecided → High
milestone: none → ubuntu-10.04
status: New → Confirmed
Matthias Klose (doko)
Changed in patch (Ubuntu):
assignee: nobody → Matthias Klose (doko)
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package patch - 2.6-2ubuntu1

---------------
patch (2.6-2ubuntu1) lucid; urgency=low

  * Build with -fno-stack-protector on sparc to pass the testsuite.
    LP: #534459.
 -- Matthias Klose <email address hidden> Mon, 05 Apr 2010 03:18:36 +0200

Changed in patch (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
StefanPotyra (sistpoty) wrote :

sorry, didn't yet manage to find a minimal test-case that is anything less than the complete patch package.
However I found another workaround: Adding assertions on the (hopefully) correct bounds in bestmatch.h seems to somehow also produce a working patch binary, patch attached (but please double-check).

Revision history for this message
StefanPotyra (sistpoty) wrote :
Revision history for this message
StefanPotyra (sistpoty) wrote :

oh, crap, attached patch is in reverted form :(

Revision history for this message
Matthias Klose (doko) wrote :

closing the GCC task, sparc is gone

Changed in gcc-4.4 (Ubuntu):
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.