cy99 / fastlz

Automatically exported from code.google.com/p/fastlz
Other
0 stars 0 forks source link

6pack and 6unpack crashes with SIGBUS on sparc undr many compiler/options combinations #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

On a sun4u machine compile with gcc version 4

sunw389:fastlz>gcc 6pack.c fastlz.c -o 6pack -g
sunw389:fastlz>gdb 6pack
GNU gdb 6.1
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.8"...
(gdb) run 6pack 6pack.6p

Program received signal SIGSEGV, Segmentation fault.
0x000120d0 in fastlz2_compress (input=0xffbdec10, length=34332,
output=0xffb9ec10) at fastlz.c:199
199         HASH_FUNCTION(hval,ip);
(gdb)

Using Sun studio 11 cc without -fast option works.

Original issue reported on code.google.com by thwill...@gmail.com on 15 Jun 2007 at 4:02

GoogleCodeExporter commented 9 years ago
The problem was with 
#define HASH_FUNCTION(v,p) { v = *((const flzuint16*)p); v ^= *((const
flzuint16*)(p+1))^(v>>(16-HASH_LOG));v &= HASH_MASK; }

This caused misaligned accesses. This caused bus error on sparc, 
or if compiled such that those misaligned accesses are trapped, 
so many traps that it became useless (used 75 times as long time).
After I changed it to 

#define HASH_FUNCTION(v,p) { v =  p[0]<<8 | p[1]; \
        v ^= (p[1]<<8|p[2])^(v>>(16-HASH_LOG));v &= HASH_MASK; }

It works very good.
Very fast.

Original comment by thwill...@gmail.com on 16 Jun 2007 at 2:31

GoogleCodeExporter commented 9 years ago
Thanks for the test and the fix!

At the moment, I can't declare that FastLZ is flawless on RISC and/or 64-bit 
machine.
But I'm working towards that (still testing it under Itanium and Xeon, which 
have the
same problem with alignment).

Original comment by ariya.hi...@gmail.com on 18 Jun 2007 at 9:19