I've reproduced it on my sparc box and investigated the failure in the
compare.sh test. During it the following command fails:
root@debian:/tmp/grib-api-1.7.0# /tmp/grib-api-1.7.0/tools/.libs/lt-grib_compare -b indicatorOfParameter,paramId,shortName /tmp/grib-api-1.7.0/data/regular_latlon_surface.grib1 /tmp/grib-api-1.7.0/data/regular_latlon_surface.grib1.1
-- count=1 shortName=2d stepRange=0 levelType=sfc level=0 --
Bus error
root@debian:/tmp/grib-api-1.7.0# gdb /tmp/grib-api-1.7.0/tools/.libs/lt-grib_compare
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "sparc-linux-gnu"...
(gdb) set args -b indicatorOfParameter,paramId,shortName /tmp/grib-api-1.7.0/data/regular_latlon_surface.grib1 /tmp/grib-api-1.7.0/data/regular_latlon_surface.grib1.1
(gdb) run
Starting program: /tmp/grib-api-1.7.0/tools/.libs/lt-grib_compare -b indicatorOfParameter,paramId,shortName /tmp/grib-api-1.7.0/data/regular_latlon_surface.grib1 /tmp/grib-api-1.7.0/data/regular_latlon_surface.grib1.1
-- count=1 shortName=2d stepRange=0 levelType=sfc level=0 --
Program received signal SIGBUS, Bus error.
grib_decode_double_array (p=0x10757f "\"\"%� B\022�", bitp=0xffabce98, nbits=16, reference_value=<value optimized out>, s=0.0009765625, d=1, size=496,
val=0x13e0b8) at grib_bits.c:205
205 val[i]= val[i] * fact + bias ;
(gdb) list
200 startBit = 0;
201 pp++;
202 }
203
204 val[i]=VALUE(*pp,startBit,remainingBits);
205 val[i]= val[i] * fact + bias ;
206 startBit+=remainingBits;
207 remainingBits=nbits;
208 }
209
(gdb) bt
#0 grib_decode_double_array (p=0x10757f "\"\"%� B\022�", bitp=0xffabce98, nbits=16, reference_value=<value optimized out>, s=0.0009765625, d=1, size=496,
val=0x13e0b8) at grib_bits.c:205
#1 0xf7e5b2e8 in unpack_double (a=0x110ce8, val=0x13e0b8, len=0xffabcf8c) at grib_accessor_class_data_simple_packing.c:340
#2 0xf7e469e8 in grib_unpack_double (a=0x110ce8, v=0x13e0b8, len=0xffabcf8c) at grib_accessor.c:173
#3 0xf7e80cac in _grib_get_double_array_internal (h=0x107968, a=0x110ce8, val=0x13e0b8, buffer_len=496, decoded_length=0xffabd03c) at grib_value.c:591
#4 0x00011de0 in compare_values (h1=0x107968, h2=0x289e8, name=0xf43b0 "values") at grib_compare.c:329
#5 0x000127fc in grib_tool_new_handle_action (options=<value optimized out>, h=0x289e8) at grib_compare.c:485
#6 0x00013fd4 in grib_tool (argc=<value optimized out>, argv=<value optimized out>) at grib_tools.c:263
#7 0xf7b8bc58 in __libc_start_main () from /lib/libc.so.6
#8 0x00011758 in _start ()
(gdb) info reg pc
pc 0xf7e6d884 0xf7e6d884 <grib_decode_double_array+532>
(gdb) disass 0xf7e6d884
Dump of assembler code for function grib_decode_double_array:
[...]
0xf7e6d870 <grib_decode_double_array+512>: cmp %i2, 0x20
0xf7e6d874 <grib_decode_double_array+516>: sub %o5, %i5, %i4
0xf7e6d878 <grib_decode_double_array+520>: inc %g4
0xf7e6d87c <grib_decode_double_array+524>: be 0xf7e6d8e0 <grib_decode_double_array+624>
0xf7e6d880 <grib_decode_double_array+528>: mov %o7, %g3
0xf7e6d884 <grib_decode_double_array+532>: ld [ %i0 ], %g1
0xf7e6d888 <grib_decode_double_array+536>: sra %g1, %i4, %g1
0xf7e6d88c <grib_decode_double_array+540>: and %g3, %g1, %g1
0xf7e6d890 <grib_decode_double_array+544>: st %g1, [ %fp + -16 ]
0xf7e6d894 <grib_decode_double_array+548>: ld [ %fp + -16 ], %f14
0xf7e6d898 <grib_decode_double_array+552>: fitod %f14, %f8
0xf7e6d89c <grib_decode_double_array+556>: fmuld %f10, %f8, %f8
0xf7e6d8a0 <grib_decode_double_array+560>: faddd %f8, %f12, %f8
0xf7e6d8a4 <grib_decode_double_array+564>: std %f8, [ %o1 + %i3 ]
0xf7e6d8a8 <grib_decode_double_array+568>: cmp %o2, %g4
0xf7e6d8ac <grib_decode_double_array+572>: bleu 0xf7e6d824 <grib_decode_double_array+436>
0xf7e6d8b0 <grib_decode_double_array+576>: mov %g4, %g1
0xf7e6d8b4 <grib_decode_double_array+580>: cmp %i5, 0x20
0xf7e6d8b8 <grib_decode_double_array+584>: bne 0xf7e6d86c <grib_decode_double_array+508>
0xf7e6d8bc <grib_decode_double_array+588>: sll %g1, 3, %i3
0xf7e6d8c0 <grib_decode_double_array+592>: clr %i5
0xf7e6d8c4 <grib_decode_double_array+596>: add %i0, 4, %i0
0xf7e6d8c8 <grib_decode_double_array+600>: add %i5, %i2, %i5
0xf7e6d8cc <grib_decode_double_array+604>: cmp %i2, 0x20
0xf7e6d8d0 <grib_decode_double_array+608>: sub %o5, %i5, %i4
0xf7e6d8d4 <grib_decode_double_array+612>: inc %g4
0xf7e6d8d8 <grib_decode_double_array+616>: bne 0xf7e6d884 <grib_decode_double_array+532>
0xf7e6d8dc <grib_decode_double_array+620>: mov %o7, %g3
0xf7e6d8e0 <grib_decode_double_array+624>: b 0xf7e6d884 <grib_decode_double_array+532>
0xf7e6d8e4 <grib_decode_double_array+628>: mov %g2, %g3
End of assembler dump.
(gdb) info reg i0
i0 0x10757f 1078655
(gdb) print p
$1 = (const unsigned char *) 0x10757f "\"\"%� B\022�"
(gdb)
So, it looks like the value of pointer p passed to the
grib_decode_double_array is 0x10757f, so it's not word-aligned. Later it
is cast directly to a pointer to long (pp) without any concern about its
alignment. Attempt to read in the long from a location which is not
word-aligned will get a SIGBUS on any platform with strict alignment
requirements, and that's what happens here.
Best regards,
--
Jurij Smakov jurij DeleteThis @wooyd.org
Key:
http://www.wooyd.org/pgpkey/ KeyID: C99E03CC
--
To UNSUBSCRIBE, email to debian-bugs-dist-REQUEST DeleteThis @lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster DeleteThis @lists.debian.org