Debian Bug report logs - #443880
SIGSEGV on hppa, ia64, sparc

version graph

Package: zziplib; Maintainer for zziplib is Scott Howard <showard@debian.org>;

Reported by: Enrico Tassi <gareuselesinge@debian.org>

Date: Mon, 24 Sep 2007 19:42:01 UTC

Severity: serious

Fixed in versions zziplib/0.13.49-3.1, zziplib/0.13.49-4

Done: Anibal Monsalve Salazar <anibal@debian.org>

Bug is archived. No further changes may be made.

Forwarded to Guido Draheim <guidod@gmx.de>

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Anibal Monsalve Salazar <anibal@debian.org>:
Bug#443880; Package zziplib. Full text and rfc822 format available.

Acknowledgement sent to Enrico Tassi <gareuselesinge@debian.org>:
New Bug report received and forwarded. Copy sent to Anibal Monsalve Salazar <anibal@debian.org>. Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: Enrico Tassi <gareuselesinge@debian.org>
To: submit@bugs.debian.org
Subject: SIGSEGV on hppa, ia64, sparc
Date: Mon, 24 Sep 2007 21:40:24 +0100
[Message part 1 (text/plain, inline)]
Package: zziplib
Severity: serious

--- Please enter the report below this line. ---
This snippet simply gets a SIGSEGV on the mentioned archs:

  #include <zzip/zzip.h>
  
  int main(){
    const char *zipfilename = "luazip.zip";
  
    ZZIP_DIR* pf;
    pf = zzip_dir_open(zipfilename, 0);
    return 0;
  }

I attach the zipfile, but I don't think it has something special
This is the backtrace:

  #0  0x403078f0 in __zzip_parse_root_directory () from
  /usr/lib/libzzip-0.so.13
  #1  0x40307c2c in zzip_dir_fdopen_ext_io () from
  /usr/lib/libzzip-0.so.13
  #2  0x00010560 in main () at test.c:7

The suspect code is in zip.c function __zzip_parse_root_directory

  d = (void*)(fd_map+zz_fd_gap+zz_offset);

When d is dereferenced you get a SIGSEGV. I did not investigate further,
since this line is enough misterious for me...

Cheers

--- System information. ---
Architecture: amd64
Kernel:       Linux 2.6.22-1-amd64

Debian Release: lenny/sid
  500 unstable        www.debian-multimedia.org 
  500 unstable        ftp.it.debian.org 
  500 testing         security.debian.org 

--- Package information. ---
Depends       (Version) | Installed
=======================-+-===========
                        | 


-- 
Enrico Tassi
[luazip.zip (application/zip, attachment)]

Reply sent to 443880@bugs.debian.org, Enrico Tassi <gareuselesinge@debian.org>:
You have marked Bug as forwarded. Full text and rfc822 format available.

Message #8 received at 443880-forwarded@bugs.debian.org (full text, mbox):

From: Aníbal Monsalve Salazar <anibal@debian.org>
To: Guido Draheim <guidod@gmx.de>
Cc: Enrico Tassi <gareuselesinge@debian.org>, 443880-forwarded@bugs.debian.org
Subject: Re: Bug#443880: SIGSEGV on hppa, ia64, sparc
Date: Tue, 2 Oct 2007 09:59:36 +1000
[Message part 1 (text/plain, inline)]
On Mon, Sep 24, 2007 at 09:40:24PM +0100, Enrico Tassi wrote:
>Package: zziplib
>Severity: serious
>
>--- Please enter the report below this line. ---
>This snippet simply gets a SIGSEGV on the mentioned archs:
>
>  #include <zzip/zzip.h>
>  
>  int main(){
>    const char *zipfilename = "luazip.zip";
>  
>    ZZIP_DIR* pf;
>    pf = zzip_dir_open(zipfilename, 0);
>    return 0;
>  }
>
>I attach the zipfile, but I don't think it has something special
>This is the backtrace:
>
>  #0  0x403078f0 in __zzip_parse_root_directory () from
>  /usr/lib/libzzip-0.so.13
>  #1  0x40307c2c in zzip_dir_fdopen_ext_io () from
>  /usr/lib/libzzip-0.so.13
>  #2  0x00010560 in main () at test.c:7
>
>The suspect code is in zip.c function __zzip_parse_root_directory
>
>  d = (void*)(fd_map+zz_fd_gap+zz_offset);
>
>When d is dereferenced you get a SIGSEGV. I did not investigate further,
>since this line is enough misterious for me...
>
>Cheers
>
>--- System information. ---
>Architecture: amd64
>Kernel:       Linux 2.6.22-1-amd64
>
>Debian Release: lenny/sid
>  500 unstable        www.debian-multimedia.org 
>  500 unstable        ftp.it.debian.org 
>  500 testing         security.debian.org 
>
>--- Package information. ---
>Depends       (Version) | Installed
>=======================-+-===========
>                        | 
>
>
>-- 
>Enrico Tassi

Hello Guido,

I have forwarded this bug report to you. Please reply to
443880@bugs.debian.org to keep
http://bugs.debian.org/443880 updated.

Thank you,

Aníbal Monsalve Salazar
-- 
http://v7w.com/anibal
[signature.asc (application/pgp-signature, inline)]

Information forwarded to debian-bugs-dist@lists.debian.org, Anibal Monsalve Salazar <anibal@debian.org>:
Bug#443880; Package zziplib. Full text and rfc822 format available.

Acknowledgement sent to "brian m. carlson" <sandals@crustytoothpaste.ath.cx>:
Extra info received and forwarded to list. Copy sent to Anibal Monsalve Salazar <anibal@debian.org>. Full text and rfc822 format available.

Message #13 received at 443880@bugs.debian.org (full text, mbox):

From: "brian m. carlson" <sandals@crustytoothpaste.ath.cx>
To: 443880@bugs.debian.org
Cc: control@bugs.debian.org
Subject: libzzip crash is unaligned access
Date: Wed, 7 Nov 2007 00:38:23 +0000
[Message part 1 (text/plain, inline)]
tags 443880 + patch
kthxbye

The crash in __zzip_parse_root_directory is a bus error on sparc, which 
is a dead giveaway that it's an unaligned access.  The problem is that 
d is a zzip_disk_entry, which is required to be aligned, but zz_offset 
is not guaranteed to be a multiple of sizeof(*d).

In fact, line 456 explicitly updates zz_offset to something that is 
often *not* a multiple of 4, so using a char * (fd_map, from mmap) will 
result in an unaligned access.  The way to solve this is to explicitly 
allocate memory for d, then memcpy the data from fd_map to d, since 
memcpy is guaranteed to work for memory of any alignment.  

An untested patch to do this is attached.
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 713 440 7475 | http://crustytoothpaste.ath.cx/~bmc | My opinion only
a typesetting engine: http://crustytoothpaste.ath.cx/~bmc/code/thwack
OpenPGP: RSA v4 4096b 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
[zziplib.patch (text/x-diff, attachment)]
[signature.asc (application/pgp-signature, inline)]

Tags added: patch Request was from "brian m. carlson" <sandals@crustytoothpaste.ath.cx> to control@bugs.debian.org. (Wed, 07 Nov 2007 00:39:02 GMT) Full text and rfc822 format available.

Information forwarded to debian-bugs-dist@lists.debian.org, Anibal Monsalve Salazar <anibal@debian.org>:
Bug#443880; Package zziplib. Full text and rfc822 format available.

Acknowledgement sent to Aníbal Monsalve Salazar <anibal@v7w.com>:
Extra info received and forwarded to list. Copy sent to Anibal Monsalve Salazar <anibal@debian.org>. Full text and rfc822 format available.

Message #20 received at 443880@bugs.debian.org (full text, mbox):

From: Aníbal Monsalve Salazar <anibal@v7w.com>
To: Enrico Tassi <gareuselesinge@debian.org>
Cc: "brian m. carlson" <sandals@crustytoothpaste.ath.cx>, Guido Draheim <guidod@gmx.de>, 443880@bugs.debian.org
Subject: Re: Bug#443880: libzzip crash is unaligned access
Date: Wed, 7 Nov 2007 21:15:18 +1100
[Message part 1 (text/plain, inline)]
On Wed, Nov 07, 2007 at 12:38:23AM +0000, brian m. carlson wrote:
>tags 443880 + patch
>kthxbye
>
>The crash in __zzip_parse_root_directory is a bus error on sparc, which 
>is a dead giveaway that it's an unaligned access.  The problem is that 
>d is a zzip_disk_entry, which is required to be aligned, but zz_offset 
>is not guaranteed to be a multiple of sizeof(*d).
>
>In fact, line 456 explicitly updates zz_offset to something that is 
>often *not* a multiple of 4, so using a char * (fd_map, from mmap) will 
>result in an unaligned access.  The way to solve this is to explicitly 
>allocate memory for d, then memcpy the data from fd_map to d, since 
>memcpy is guaranteed to work for memory of any alignment.  
>
>An untested patch to do this is attached.

Thank you!

>-- 
>brian m. carlson / brian with sandals: Houston, Texas, US
>+1 713 440 7475 | http://crustytoothpaste.ath.cx/~bmc | My opinion only
>a typesetting engine: http://crustytoothpaste.ath.cx/~bmc/code/thwack
>OpenPGP: RSA v4 4096b 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187

Enrico, please test the new debian packages available at:

http://people.debian.org/~anibal/zziplib/

>--- zip.c.orig	2007-11-06 23:59:24.000000000 +0000
>+++ zip.c	2007-11-07 00:35:40.000000000 +0000
>@@ -402,7 +402,10 @@
>         uint16_t u_extras, u_comment, u_namlen;
> 
>         if (fd_map) 
>-	{ d = (void*)(fd_map+zz_fd_gap+zz_offset); } /* fd_map+fd_gap==u_rootseek */
>+	{
>+            d = &dirent;
>+            memcpy(d, fd_map+zz_fd_gap+zz_offset, sizeof(*d)); /* fd_map+fd_gap==u_rootseek */
>+        }
>         else
>         {
>             if (io->fd.seeks(fd, zz_rootseek+zz_offset, SEEK_SET) < 0)
[signature.asc (application/pgp-signature, inline)]

Reply sent to Anibal Monsalve Salazar <anibal@debian.org>:
You have taken responsibility. Full text and rfc822 format available.

Notification sent to Enrico Tassi <gareuselesinge@debian.org>:
Bug acknowledged by developer. Full text and rfc822 format available.

Message #25 received at 443880-close@bugs.debian.org (full text, mbox):

From: Anibal Monsalve Salazar <anibal@debian.org>
To: 443880-close@bugs.debian.org
Subject: Bug#443880: fixed in zziplib 0.13.49-3
Date: Mon, 12 Nov 2007 05:28:01 +0000
Source: zziplib
Source-Version: 0.13.49-3

We believe that the bug you reported is fixed in the latest version of
zziplib, which is due to be installed in the Debian FTP archive:

libzzip-0-13_0.13.49-3_amd64.deb
  to pool/main/z/zziplib/libzzip-0-13_0.13.49-3_amd64.deb
libzzip-dev_0.13.49-3_amd64.deb
  to pool/main/z/zziplib/libzzip-dev_0.13.49-3_amd64.deb
zziplib-bin_0.13.49-3_amd64.deb
  to pool/main/z/zziplib/zziplib-bin_0.13.49-3_amd64.deb
zziplib_0.13.49-3.diff.gz
  to pool/main/z/zziplib/zziplib_0.13.49-3.diff.gz
zziplib_0.13.49-3.dsc
  to pool/main/z/zziplib/zziplib_0.13.49-3.dsc



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 443880@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Anibal Monsalve Salazar <anibal@debian.org> (supplier of updated zziplib package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.7
Date: Wed, 07 Nov 2007 17:43:35 +1100
Source: zziplib
Binary: libzzip-dev zziplib-bin libzzip-0-13
Architecture: source amd64
Version: 0.13.49-3
Distribution: unstable
Urgency: low
Maintainer: Anibal Monsalve Salazar <anibal@debian.org>
Changed-By: Anibal Monsalve Salazar <anibal@debian.org>
Description: 
 libzzip-0-13 - library providing read access on ZIP-archives - library
 libzzip-dev - library providing read access on ZIP-archives - development
 zziplib-bin - library providing read access on ZIP-archives - binaries
Closes: 442779 443880
Changes: 
 zziplib (0.13.49-3) unstable; urgency=low
 .
   * Fixed SIGSEGV on hppa, ia64, sparc, closes: #443880.
     Patch by brian m. carlson <sandals@crustytoothpaste.ath.cx>
     Patch: 01-zip.c.patch
   * Fixed FTBFS if build twice in a row, closes: #442779.
   * Build-depends on quilt
Files: 
 7727c932a3e3e89969e9fb3359c229d9 658 libs optional zziplib_0.13.49-3.dsc
 28fb5f0f3da6d680e7dd497105cdd218 6537 libs optional zziplib_0.13.49-3.diff.gz
 234f99567d0828130f5786d384f6fa0f 36638 utils optional zziplib-bin_0.13.49-3_amd64.deb
 71bbe0b1ccb76275d0cedc7666a127a1 51398 libs optional libzzip-0-13_0.13.49-3_amd64.deb
 eb9ce06bc2f54c58258fe5fcb5573c72 107096 libdevel optional libzzip-dev_0.13.49-3_amd64.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHNqrMgY5NIXPNpFURAj+cAKCQ0xAxIZ+5/s0qrewdA5gQcsxPsACfclHq
gRTww6745T0C4ScqbaMNyFU=
=oGZk
-----END PGP SIGNATURE-----





Information forwarded to debian-bugs-dist@lists.debian.org, Anibal Monsalve Salazar <anibal@debian.org>:
Bug#443880; Package zziplib. Full text and rfc822 format available.

Acknowledgement sent to Enrico Tassi <gareuselesinge@debian.org>:
Extra info received and forwarded to list. Copy sent to Anibal Monsalve Salazar <anibal@debian.org>. Full text and rfc822 format available.

Message #30 received at 443880@bugs.debian.org (full text, mbox):

From: Enrico Tassi <gareuselesinge@debian.org>
To: 443880@bugs.debian.org, control@bugs.debian.org
Subject: Bug#443880: fixed in zziplib 0.13.49-3
Date: Sat, 17 Nov 2007 13:11:56 +0100
reopen 443880
thanks

It seems the patch did not work as expected, since the test still fails:
 
  http://buildd.debian.org/fetch.cgi?pkg=lua-zip;ver=1.2.3-4;arch=ia64;stamp=1195299518

I'll try to test again the code snippet later, since the chroots I've
tried are not up to date and still provide 0.13.49-2

Cheers
-- 
Enrico Tassi




Bug reopened, originator not changed. Request was from Enrico Tassi <gareuselesinge@debian.org> to control@bugs.debian.org. (Sat, 17 Nov 2007 12:15:03 GMT) Full text and rfc822 format available.

Information forwarded to debian-bugs-dist@lists.debian.org, Anibal Monsalve Salazar <anibal@debian.org>:
Bug#443880; Package zziplib. Full text and rfc822 format available.

Acknowledgement sent to Jurij Smakov <jurij@wooyd.org>:
Extra info received and forwarded to list. Copy sent to Anibal Monsalve Salazar <anibal@debian.org>. Full text and rfc822 format available.

Message #37 received at 443880@bugs.debian.org (full text, mbox):

From: Jurij Smakov <jurij@wooyd.org>
To: 443880@bugs.debian.org
Cc: 443880-submitter@bugs.debian.org, Guido Draheim <guidod@gmx.de>
Subject: SIGBUS on sparc
Date: Sun, 2 Mar 2008 20:38:16 +0000
Hi,

I've done further investigation since it's still failing. A detailed
trace I've obtained from a SIGBUS during lua-zip build:

Core was generated by `lua5.1 -l zip tests/test_zip.lua'.
Program terminated with signal 10, Bus error.
#0  0x7008293c in __zzip_parse_root_directory (fd=3, 
trailer=0xffd66d58, hdr_return=0x47dc0, io=0x70098020) at 
../../zzip/zip.c:440
440             hdr->d_crc32 = zzip_disk_entry_get_crc32 (d);
(gdb) bt full
#0  0x7008293c in __zzip_parse_root_directory (fd=3, 
trailer=0xffd66d58, hdr_return=0x47dc0, io=0x70098020) at 
../../zzip/zip.c:440
        __bsx = 4292242562
        d = (struct zzip_disk_entry *) 0xffd66c82
        u_extras = 0
        u_comment = 0
        u_namlen = 6
        dirent = {z_magic = "PK\001\002", z_encoder = {version = 
"\024", ostype = ""}, z_extract = {version = "\024", ostype = ""}, 
z_flags = "\000", z_compr = "\b", z_dostime = {
    time = ")£", date = "Ù0"}, z_crc32 = "㦢O", z_csize = 
"|\000\000", z_usize = "\237\000\000", z_namlen = "\006", z_extras = 
"\000", z_comment = "\000", z_diskstart = "\000", 
  z_filetype = "\001", z_filemode = " \000\000", z_offset = 
"\000\000\000"}
        hdr = (struct zzip_dir_hdr *) 0x47ec0
        hdr0 = (struct zzip_dir_hdr *) 0x47ec0
        p_reclen = (uint16_t *) 0x0
        entries = 4
        zz_offset = 0
        fd_map = 0x70074000 <Address 0x70074000 out of bounds>
        zz_fd_gap = 4826
        zz_entries = 4
        zz_rootsize = 214
        zz_rootseek = 4826
#1  0x70083238 in __zzip_dir_parse (dir=0x47da8) at 
../../zzip/zip.c:661
        rv = ZZIP_NO_ERROR
        filesize = 5062
        trailer = {zz_tail = 0x13b0, zz_for_correct_rootseek = 
0x703241ac, zz_entries = 4, zz_finalentries = 4, zz_rootseek = 4826, 
zz_rootsize = 214}
#2  0x700830b0 in zzip_dir_fdopen_ext_io (fd=3, errcode_p=0x0, 
ext=0x70098014, io=0x70098020) at ../../zzip/zip.c:622
        rv = 270344
        dir = (ZZIP_DIR *) 0x47da8
#3  0x700834ec in zzip_dir_open_ext_io (filename=0x4a400 "luazip.zip", 
e=0x0, ext=0x70098014, io=0x70098020) at ../../zzip/zip.c:726
        fd = 3
#4  0x7008343c in zzip_dir_open (filename=0x4a400 "luazip.zip", e=0x0) 
at ../../zzip/zip.c:708
No locals.
#5  0x700618e0 in ?? ()
No symbol table info available.
#6  0x700618e4 in ?? ()
No symbol table info available.
Backtrace stopped: previous frame identical to this frame (corrupt 
stack?)
(gdb) print &d->z_crc32
$1 = (zzip_byte_t (*)[4]) 0xffd66c92

Here's the problem: z_crc32 (and all other fields in this structure)
are defined as zzip_byte_t arrays, which means that compiler does not
care about their alignment. When an attempt is made to cast z_crc32
to a 32-bit integer, it gets a SIGBUS, since z_crc32 is only half-word
aligned.

I don't see a way to fix this without a major redesign or making
all the memory-accessing/casting macros in format.h to use memcpy 
(ugly).

Best regards,
-- 
Jurij Smakov                                           jurij@wooyd.org
Key: http://www.wooyd.org/pgpkey/                      KeyID: C99E03CC




Message sent on to Enrico Tassi <gareuselesinge@debian.org>:
Bug#443880. Full text and rfc822 format available.

Information forwarded to debian-bugs-dist@lists.debian.org, Anibal Monsalve Salazar <anibal@debian.org>:
Bug#443880; Package zziplib. Full text and rfc822 format available.

Acknowledgement sent to Guido Draheim <guidod-2007-@gmx.de>:
Extra info received and forwarded to list. Copy sent to Anibal Monsalve Salazar <anibal@debian.org>. Full text and rfc822 format available.

Message #45 received at 443880@bugs.debian.org (full text, mbox):

From: Guido Draheim <guidod-2007-@gmx.de>
To: Jurij Smakov <jurij@wooyd.org>
Cc: 443880@bugs.debian.org, 443880-submitter@bugs.debian.org, Guido Draheim <guidod@gmx.de>
Subject: Re: SIGBUS on sparc
Date: Mon, 03 Mar 2008 11:22:19 +0100
Jurij Smakov schrieb:
> Hi,
> 
> I've done further investigation since it's still failing. A detailed
> trace I've obtained from a SIGBUS during lua-zip build:
> 
> Core was generated by `lua5.1 -l zip tests/test_zip.lua'.
> Program terminated with signal 10, Bus error.
> #0  0x7008293c in __zzip_parse_root_directory (fd=3, 
> trailer=0xffd66d58, hdr_return=0x47dc0, io=0x70098020) at 
> ../../zzip/zip.c:440
> 440             hdr->d_crc32 = zzip_disk_entry_get_crc32 (d);
> (gdb) bt full
> #0  0x7008293c in __zzip_parse_root_directory (fd=3, 
> trailer=0xffd66d58, hdr_return=0x47dc0, io=0x70098020) at 
> ../../zzip/zip.c:440
>         __bsx = 4292242562
>         d = (struct zzip_disk_entry *) 0xffd66c82
>         u_extras = 0
>         u_comment = 0
>         u_namlen = 6
>         dirent = {z_magic = "PK\001\002", z_encoder = {version = 
> "\024", ostype = ""}, z_extract = {version = "\024", ostype = ""}, 
> z_flags = "\000", z_compr = "\b", z_dostime = {
>     time = ")£", date = "Ù0"}, z_crc32 = "㦢O", z_csize = 
> "|\000\000", z_usize = "\237\000\000", z_namlen = "\006", z_extras = 
> "\000", z_comment = "\000", z_diskstart = "\000", 
>   z_filetype = "\001", z_filemode = " \000\000", z_offset = 
> "\000\000\000"}
>         hdr = (struct zzip_dir_hdr *) 0x47ec0
>         hdr0 = (struct zzip_dir_hdr *) 0x47ec0
>         p_reclen = (uint16_t *) 0x0
>         entries = 4
>         zz_offset = 0
>         fd_map = 0x70074000 <Address 0x70074000 out of bounds>
>         zz_fd_gap = 4826
>         zz_entries = 4
>         zz_rootsize = 214
>         zz_rootseek = 4826
> #1  0x70083238 in __zzip_dir_parse (dir=0x47da8) at 
> ../../zzip/zip.c:661
>         rv = ZZIP_NO_ERROR
>         filesize = 5062
>         trailer = {zz_tail = 0x13b0, zz_for_correct_rootseek = 
> 0x703241ac, zz_entries = 4, zz_finalentries = 4, zz_rootseek = 4826, 
> zz_rootsize = 214}
> #2  0x700830b0 in zzip_dir_fdopen_ext_io (fd=3, errcode_p=0x0, 
> ext=0x70098014, io=0x70098020) at ../../zzip/zip.c:622
>         rv = 270344
>         dir = (ZZIP_DIR *) 0x47da8
> #3  0x700834ec in zzip_dir_open_ext_io (filename=0x4a400 "luazip.zip", 
> e=0x0, ext=0x70098014, io=0x70098020) at ../../zzip/zip.c:726
>         fd = 3
> #4  0x7008343c in zzip_dir_open (filename=0x4a400 "luazip.zip", e=0x0) 
> at ../../zzip/zip.c:708
> No locals.
> #5  0x700618e0 in ?? ()
> No symbol table info available.
> #6  0x700618e4 in ?? ()
> No symbol table info available.
> Backtrace stopped: previous frame identical to this frame (corrupt 
> stack?)
> (gdb) print &d->z_crc32
> $1 = (zzip_byte_t (*)[4]) 0xffd66c92
> 
> Here's the problem: z_crc32 (and all other fields in this structure)
> are defined as zzip_byte_t arrays, which means that compiler does not
> care about their alignment. When an attempt is made to cast z_crc32
> to a 32-bit integer, it gets a SIGBUS, since z_crc32 is only half-word
> aligned.
> 
> I don't see a way to fix this without a major redesign or making
> all the memory-accessing/casting macros in format.h to use memcpy 
> (ugly).
> 
> Best regards,

There is no redesign required - this problem can only occur on non-x86 little-endian platforms.

You did not tell about that detail but I can guess it from the result. In fetch.h there is
#define zzip_file_header_get_crc32(__p)      ZZIP_GET32((__p)->z_crc32)
and that ZZIP_GET32 can be defined in a way that it would fetch each byte seperately. This is already done on a lot of platforms - the definition is dependent on ZZIP_WORDS_BIGENDIAN and covers acrchitectures like SPARC which have aligned word access 
as well. However, SPARC is big-endian as have been all the other test platforms in the lab. So, what's your target platform currently? If I am guessing right then would need to redefine the #ifdefs and configure detections in such a way that it would 
enable a bytewise access macro on a litte-endian platform right there in fetch.h

cheers, Guido





Message sent on to Enrico Tassi <gareuselesinge@debian.org>:
Bug#443880. Full text and rfc822 format available.

Information forwarded to debian-bugs-dist@lists.debian.org, Anibal Monsalve Salazar <anibal@debian.org>:
Bug#443880; Package zziplib. Full text and rfc822 format available.

Acknowledgement sent to Jurij Smakov <jurij@wooyd.org>:
Extra info received and forwarded to list. Copy sent to Anibal Monsalve Salazar <anibal@debian.org>. Full text and rfc822 format available.

Message #53 received at 443880@bugs.debian.org (full text, mbox):

From: Jurij Smakov <jurij@wooyd.org>
To: Guido Draheim <guidod-2007-@gmx.de>
Cc: Jurij Smakov <jurij@wooyd.org>, 443880@bugs.debian.org, 443880-submitter@bugs.debian.org, Guido Draheim <guidod@gmx.de>
Subject: Re: SIGBUS on sparc
Date: Mon, 3 Mar 2008 23:29:08 +0000
On Mon, Mar 03, 2008 at 11:22:19AM +0100, Guido Draheim wrote:
[...]
> There is no redesign required - this problem can only occur on non-x86 little-endian platforms.
>
> You did not tell about that detail but I can guess it from the result. In fetch.h there is
> #define zzip_file_header_get_crc32(__p)      ZZIP_GET32((__p)->z_crc32)
> and that ZZIP_GET32 can be defined in a way that it would fetch each byte 
> seperately. This is already done on a lot of platforms - the definition 
> is dependent on ZZIP_WORDS_BIGENDIAN and covers acrchitectures like SPARC 
> which have aligned word access as well. However, SPARC is big-endian as 
> have been all the other test platforms in the lab. So, what's your target 
> platform currently? If I am guessing right then would need to redefine 
> the #ifdefs and configure detections in such a way that it would enable a 
> bytewise access macro on a litte-endian platform right there in fetch.h

Sparc is big-endian, but that's not what causes a problem here (even 
though it would be nice to check that endianness is detected correctly 
for sparc). Let's say that the macro which will get used is this one:

# define ZZIP_GET32(__p)         bswap_32(*(uint32_t*)(__p))

This will only work on sparc if the address __p is word-aligned 
(divisible by 4). Compiler is likely to generate a single load-word
instruction for that, and if __p is not word-aligned, then the process
will get a SIGBUS. Normally, it happens automatically, i.e. if you 
define an int (of size 4) field inside a struct, then compiler will
take care of allocating memory for it in such a way that it is 
word-aligned. However, since the structures in format.h are defined
mostly using arrays of zzip_byte_t, there is no way the compiler can 
guess which of them should be aligned, so it places them arbitrarily.
Thus, attempt to cast the value to uint32_t fails.

Best regards,
-- 
Jurij Smakov                                           jurij@wooyd.org
Key: http://www.wooyd.org/pgpkey/                      KeyID: C99E03CC




Message sent on to Enrico Tassi <gareuselesinge@debian.org>:
Bug#443880. Full text and rfc822 format available.

Tags removed: patch Request was from Andreas Barth <aba@not.so.argh.org> to control@bugs.debian.org. (Sun, 16 Mar 2008 22:15:06 GMT) Full text and rfc822 format available.

Information forwarded to debian-bugs-dist@lists.debian.org, Anibal Monsalve Salazar <anibal@debian.org>:
Bug#443880; Package zziplib. Full text and rfc822 format available.

Acknowledgement sent to Guido Draheim <guidod-2007-@gmx.de>:
Extra info received and forwarded to list. Copy sent to Anibal Monsalve Salazar <anibal@debian.org>. Full text and rfc822 format available.

Message #63 received at 443880@bugs.debian.org (full text, mbox):

From: Guido Draheim <guidod-2007-@gmx.de>
To: Jurij Smakov <jurij@wooyd.org>
Cc: 443880@bugs.debian.org, 443880-submitter@bugs.debian.org, Guido Draheim <guidod@gmx.de>
Subject: Re: SIGBUS on sparc
Date: Sat, 22 Mar 2008 21:48:02 +0100
Jurij Smakov schrieb:
> On Mon, Mar 03, 2008 at 11:22:19AM +0100, Guido Draheim wrote:
> [...]
>> There is no redesign required - this problem can only occur on non-x86 little-endian platforms.
>>
>> You did not tell about that detail but I can guess it from the result. In fetch.h there is
>> #define zzip_file_header_get_crc32(__p)      ZZIP_GET32((__p)->z_crc32)
>> and that ZZIP_GET32 can be defined in a way that it would fetch each byte 
>> seperately. This is already done on a lot of platforms - the definition 
>> is dependent on ZZIP_WORDS_BIGENDIAN and covers acrchitectures like SPARC 
>> which have aligned word access as well. However, SPARC is big-endian as 
>> have been all the other test platforms in the lab. So, what's your target 
>> platform currently? If I am guessing right then would need to redefine 
>> the #ifdefs and configure detections in such a way that it would enable a 
>> bytewise access macro on a litte-endian platform right there in fetch.h
> 
> Sparc is big-endian, but that's not what causes a problem here (even 
> though it would be nice to check that endianness is detected correctly 
> for sparc). Let's say that the macro which will get used is this one:
> 
> # define ZZIP_GET32(__p)         bswap_32(*(uint32_t*)(__p))
> 
> This will only work on sparc if the address __p is word-aligned 
> (divisible by 4). Compiler is likely to generate a single load-word
> instruction for that, and if __p is not word-aligned, then the process
> will get a SIGBUS. Normally, it happens automatically, i.e. if you 
> define an int (of size 4) field inside a struct, then compiler will
> take care of allocating memory for it in such a way that it is 
> word-aligned. However, since the structures in format.h are defined
> mostly using arrays of zzip_byte_t, there is no way the compiler can 
> guess which of them should be aligned, so it places them arbitrarily.
> Thus, attempt to cast the value to uint32_t fails.
> 
> Best regards,

Hi Jurij,

checking into the codebase I find that there is already a configure time
check for ZZIP_HAVE_ALIGNED_ACCESS_REQUIRED - is that being enabled in the
generated $build/zzip/_config ?

I would like to disable the Linux bswap optimization in that case (so it is
left enabled for all other Linux platforms that allow misaligned access).

I am going to commit a change that looks for that additional configure
value anyway. I hope this fixes the problem.

cheers, Guido







Message sent on to Enrico Tassi <gareuselesinge@debian.org>:
Bug#443880. Full text and rfc822 format available.

Information forwarded to debian-bugs-dist@lists.debian.org, Anibal Monsalve Salazar <anibal@debian.org>:
Bug#443880; Package zziplib. Full text and rfc822 format available.

Acknowledgement sent to Steve McIntyre <steve@einval.com>:
Extra info received and forwarded to list. Copy sent to Anibal Monsalve Salazar <anibal@debian.org>. Full text and rfc822 format available.

Message #71 received at 443880@bugs.debian.org (full text, mbox):

From: Steve McIntyre <steve@einval.com>
To: 443880@bugs.debian.org
Subject: This is a bug on *any* platform with strict alignment
Date: Sat, 5 Apr 2008 16:35:03 +0100
[Message part 1 (text/plain, inline)]
Hi,

I can reproduce this easily on sparc:

steve@brick:~/443880$ ./test 
Bus error

On alpha it runs, but the kernel has to fix up exceptions in the
background:

steve@war:~/433880$ ./test 
steve@war:~/433880$ dmesg | tail -4
test(20637): unaligned trap at 0000000120002d84: 000000011f41b4aa 28 2
test(20637): unaligned trap at 0000000120002d84: 000000011f41b4aa 28 2
test(20637): unaligned trap at 0000000120002d84: 000000011f41b4aa 28 2
test(20637): unaligned trap at 0000000120002d84: 000000011f41b4aa 28 2

By hitting the unaligned trap, the performance of the program will be
destroyed. The right answer is to write clean accessor functions to
the mis-aligned data. I'll have a patch shortly that does exactly
that.

-- 
Steve McIntyre, Cambridge, UK.                                steve@einval.com
"C++ ate my sanity" -- Jon Rabone
[signature.asc (application/pgp-signature, inline)]

Reply sent to Steve McIntyre <93sam@debian.org>:
You have taken responsibility. Full text and rfc822 format available.

Notification sent to Enrico Tassi <gareuselesinge@debian.org>:
Bug acknowledged by developer. Full text and rfc822 format available.

Message #76 received at 443880-close@bugs.debian.org (full text, mbox):

From: Steve McIntyre <93sam@debian.org>
To: 443880-close@bugs.debian.org
Subject: Bug#443880: fixed in zziplib 0.13.49-3.1
Date: Sat, 05 Apr 2008 21:32:43 +0000
Source: zziplib
Source-Version: 0.13.49-3.1

We believe that the bug you reported is fixed in the latest version of
zziplib, which is due to be installed in the Debian FTP archive:

libzzip-0-13_0.13.49-3.1_alpha.deb
  to pool/main/z/zziplib/libzzip-0-13_0.13.49-3.1_alpha.deb
libzzip-0-13_0.13.49-3.1_amd64.deb
  to pool/main/z/zziplib/libzzip-0-13_0.13.49-3.1_amd64.deb
libzzip-0-13_0.13.49-3.1_arm.deb
  to pool/main/z/zziplib/libzzip-0-13_0.13.49-3.1_arm.deb
libzzip-0-13_0.13.49-3.1_i386.deb
  to pool/main/z/zziplib/libzzip-0-13_0.13.49-3.1_i386.deb
libzzip-0-13_0.13.49-3.1_ia64.deb
  to pool/main/z/zziplib/libzzip-0-13_0.13.49-3.1_ia64.deb
libzzip-0-13_0.13.49-3.1_mips.deb
  to pool/main/z/zziplib/libzzip-0-13_0.13.49-3.1_mips.deb
libzzip-0-13_0.13.49-3.1_powerpc.deb
  to pool/main/z/zziplib/libzzip-0-13_0.13.49-3.1_powerpc.deb
libzzip-0-13_0.13.49-3.1_sparc.deb
  to pool/main/z/zziplib/libzzip-0-13_0.13.49-3.1_sparc.deb
libzzip-dev_0.13.49-3.1_alpha.deb
  to pool/main/z/zziplib/libzzip-dev_0.13.49-3.1_alpha.deb
libzzip-dev_0.13.49-3.1_amd64.deb
  to pool/main/z/zziplib/libzzip-dev_0.13.49-3.1_amd64.deb
libzzip-dev_0.13.49-3.1_arm.deb
  to pool/main/z/zziplib/libzzip-dev_0.13.49-3.1_arm.deb
libzzip-dev_0.13.49-3.1_i386.deb
  to pool/main/z/zziplib/libzzip-dev_0.13.49-3.1_i386.deb
libzzip-dev_0.13.49-3.1_ia64.deb
  to pool/main/z/zziplib/libzzip-dev_0.13.49-3.1_ia64.deb
libzzip-dev_0.13.49-3.1_mips.deb
  to pool/main/z/zziplib/libzzip-dev_0.13.49-3.1_mips.deb
libzzip-dev_0.13.49-3.1_powerpc.deb
  to pool/main/z/zziplib/libzzip-dev_0.13.49-3.1_powerpc.deb
libzzip-dev_0.13.49-3.1_sparc.deb
  to pool/main/z/zziplib/libzzip-dev_0.13.49-3.1_sparc.deb
zziplib-bin_0.13.49-3.1_alpha.deb
  to pool/main/z/zziplib/zziplib-bin_0.13.49-3.1_alpha.deb
zziplib-bin_0.13.49-3.1_amd64.deb
  to pool/main/z/zziplib/zziplib-bin_0.13.49-3.1_amd64.deb
zziplib-bin_0.13.49-3.1_arm.deb
  to pool/main/z/zziplib/zziplib-bin_0.13.49-3.1_arm.deb
zziplib-bin_0.13.49-3.1_i386.deb
  to pool/main/z/zziplib/zziplib-bin_0.13.49-3.1_i386.deb
zziplib-bin_0.13.49-3.1_ia64.deb
  to pool/main/z/zziplib/zziplib-bin_0.13.49-3.1_ia64.deb
zziplib-bin_0.13.49-3.1_mips.deb
  to pool/main/z/zziplib/zziplib-bin_0.13.49-3.1_mips.deb
zziplib-bin_0.13.49-3.1_powerpc.deb
  to pool/main/z/zziplib/zziplib-bin_0.13.49-3.1_powerpc.deb
zziplib-bin_0.13.49-3.1_sparc.deb
  to pool/main/z/zziplib/zziplib-bin_0.13.49-3.1_sparc.deb
zziplib_0.13.49-3.1.diff.gz
  to pool/main/z/zziplib/zziplib_0.13.49-3.1.diff.gz
zziplib_0.13.49-3.1.dsc
  to pool/main/z/zziplib/zziplib_0.13.49-3.1.dsc



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 443880@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Steve McIntyre <93sam@debian.org> (supplier of updated zziplib package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.7
Date: Sat, 05 Apr 2008 17:54:27 +0100
Source: zziplib
Binary: zziplib-bin libzzip-0-13 libzzip-dev
Architecture: alpha amd64 arm i386 ia64 mips powerpc source sparc 
Version: 0.13.49-3.1
Distribution: unstable
Urgency: low
Maintainer: Anibal Monsalve Salazar <anibal@debian.org>
Changed-By: Steve McIntyre <93sam@debian.org>
Description: 
 libzzip-0-13 - library providing read access on ZIP-archives - library
 libzzip-dev - library providing read access on ZIP-archives - development
 zziplib-bin - library providing read access on ZIP-archives - binaries
Closes: 443880
Changes: 
 zziplib (0.13.49-3.1) unstable; urgency=low
 .
   * NMU from the Cambridge BSP
   * Fixed SIGBUS due to alignment problems, closes: #443880.
     Patch: 01-fetch.patch
Files: 
 005a193cad8e46d9d28543c06c596508 112952 libdevel optional libzzip-dev_0.13.49-3.1_alpha.deb
 050f178c20576f76568c3b84fb3d2a3f 40064 utils optional zziplib-bin_0.13.49-3.1_ia64.deb
 0b9b64292708f97a61a69d6b3fb7b3ef 36942 utils optional zziplib-bin_0.13.49-3.1_amd64.deb
 1cf1a6cf18c2b24181a45ebdf7727f73 106458 libdevel optional libzzip-dev_0.13.49-3.1_powerpc.deb
 1ddb2ae2e5ef7485968e22b905869d28 105460 libdevel optional libzzip-dev_0.13.49-3.1_arm.deb
 23cbea503ef5728e99d7907a2fb6d2ae 662 libs optional zziplib_0.13.49-3.1.dsc
 3552b836d4f9a1a3d7149adde1d7f695 49058 libs optional libzzip-0-13_0.13.49-3.1_mips.deb
 41fdf25dea732240c85fd9de737ea61a 118404 libdevel optional libzzip-dev_0.13.49-3.1_ia64.deb
 543492137dd5dd4daa4af5370ef794f2 103686 libdevel optional libzzip-dev_0.13.49-3.1_i386.deb
 62429aef56a6b678ba3521f2c155a693 54008 libs optional libzzip-0-13_0.13.49-3.1_alpha.deb
 631b6a96de1e5044b1cefd85f230cf21 107056 libdevel optional libzzip-dev_0.13.49-3.1_amd64.deb
 6a8108ef43d32a6306bd2d6db6c08014 36204 utils optional zziplib-bin_0.13.49-3.1_i386.deb
 77f54a7fb250c031c732fdf3254e3cb2 36818 utils optional zziplib-bin_0.13.49-3.1_arm.deb
 8cb29512361b111f319674f0208a663c 62152 libs optional libzzip-0-13_0.13.49-3.1_ia64.deb
 8e68bac83ebe1d8fc90770579c04e6ac 108082 libdevel optional libzzip-dev_0.13.49-3.1_mips.deb
 a0432e2313009b39e1fde0b9eb6b10ef 36798 utils optional zziplib-bin_0.13.49-3.1_sparc.deb
 a7718e67118bcd7fea6e325e16b5146f 38042 utils optional zziplib-bin_0.13.49-3.1_alpha.deb
 af595e4fe9e4bc4e031891b347d02e77 51752 libs optional libzzip-0-13_0.13.49-3.1_amd64.deb
 b9ee3b1d8b061b02d8d7a37f6a48f133 42606 utils optional zziplib-bin_0.13.49-3.1_powerpc.deb
 bda694f173ee09c1407ed224431799ef 47514 libs optional libzzip-0-13_0.13.49-3.1_arm.deb
 c0a1122e157aea1548f7fb941d4e754b 47748 libs optional libzzip-0-13_0.13.49-3.1_sparc.deb
 cbc30d186731f17c5f4c9f852af3c4f3 103606 libdevel optional libzzip-dev_0.13.49-3.1_sparc.deb
 d21b3221d719bbd8af3e2a2ebbb171c5 56966 libs optional libzzip-0-13_0.13.49-3.1_powerpc.deb
 d7f6e35dd0251a75e25649a51d58d5d9 49294 libs optional libzzip-0-13_0.13.49-3.1_i386.deb
 e5f46a809dc9b74e8034c56f601b3319 7208 libs optional zziplib_0.13.49-3.1.diff.gz
 f47c150617015035dda9ac1098f7a7a7 37226 utils optional zziplib-bin_0.13.49-3.1_mips.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFH9+1LfDt5cIjHwfcRAsD/AKCd/NDLuBbLcNou9b6LNlegYppA0ACdE7p7
95Sku+Wie9n0oS/x36IQZ7w=
=qcUL
-----END PGP SIGNATURE-----





Reply sent to Anibal Monsalve Salazar <anibal@debian.org>:
You have taken responsibility. Full text and rfc822 format available.

Notification sent to Enrico Tassi <gareuselesinge@debian.org>:
Bug acknowledged by developer. Full text and rfc822 format available.

Message #81 received at 443880-close@bugs.debian.org (full text, mbox):

From: Anibal Monsalve Salazar <anibal@debian.org>
To: 443880-close@bugs.debian.org
Subject: Bug#443880: fixed in zziplib 0.13.49-4
Date: Sat, 05 Apr 2008 23:47:06 +0000
Source: zziplib
Source-Version: 0.13.49-4

We believe that the bug you reported is fixed in the latest version of
zziplib, which is due to be installed in the Debian FTP archive:

libzzip-0-13_0.13.49-4_mips.deb
  to pool/main/z/zziplib/libzzip-0-13_0.13.49-4_mips.deb
libzzip-dev_0.13.49-4_mips.deb
  to pool/main/z/zziplib/libzzip-dev_0.13.49-4_mips.deb
zziplib-bin_0.13.49-4_mips.deb
  to pool/main/z/zziplib/zziplib-bin_0.13.49-4_mips.deb
zziplib_0.13.49-4.diff.gz
  to pool/main/z/zziplib/zziplib_0.13.49-4.diff.gz
zziplib_0.13.49-4.dsc
  to pool/main/z/zziplib/zziplib_0.13.49-4.dsc



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 443880@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Anibal Monsalve Salazar <anibal@debian.org> (supplier of updated zziplib package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.7
Date: Sun, 06 Apr 2008 08:13:02 +1000
Source: zziplib
Binary: zziplib-bin libzzip-0-13 libzzip-dev
Architecture: source mips
Version: 0.13.49-4
Distribution: unstable
Urgency: low
Maintainer: Anibal Monsalve Salazar <anibal@debian.org>
Changed-By: Anibal Monsalve Salazar <anibal@debian.org>
Description: 
 libzzip-0-13 - library providing read access on ZIP-archives - library
 libzzip-dev - library providing read access on ZIP-archives - development
 zziplib-bin - library providing read access on ZIP-archives - binaries
Closes: 443880
Changes: 
 zziplib (0.13.49-4) unstable; urgency=low
 .
   * NMU acknowledgement. Closes: #443880
   * Fixed the following lintian issues:
     - zziplib source: out-of-date-standards-version 3.7.2 (current is 3.7.3)
     - zziplib: description-contains-homepage
Files: 
 a3ccb6f78a19963ab7e7bc78c3c5f444 699 libs optional zziplib_0.13.49-4.dsc
 66b43c70f5867afe0ab90ffc6b9cd2a3 7070 libs optional zziplib_0.13.49-4.diff.gz
 5f69fd7123008fec6c5fa801391f761c 37032 utils optional zziplib-bin_0.13.49-4_mips.deb
 0adf395f0cdeab75a11fea2ab9cdad24 49520 libs optional libzzip-0-13_0.13.49-4_mips.deb
 40f0eb3bb0936acc8272c2262857fbd0 108982 libdevel optional libzzip-dev_0.13.49-4_mips.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFH+AzNgY5NIXPNpFURAnPqAKDN36be21eq6A3SV5ylLwg5nUzfQQCfXwhd
c/ZhTOoIPTV+8U2JuxkW6MU=
=lNCJ
-----END PGP SIGNATURE-----





Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Mon, 16 Mar 2009 10:09:15 GMT) Full text and rfc822 format available.

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Thu Apr 17 04:15:15 2014; Machine Name: beach.debian.org

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.