Page 1 of 1

whishlist SIGBUS when EIO

Posted: 2011-04-21T05:36:54-07:00
by broucaries
According to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=619134
Just noticed that display command from imagemagick sets a SIGBUS after
closing a file that it could not read:

stat("/cdrom/P5130043.JPG", {st_mode=S_IFREG|0555, st_size=8206, ...}) = 0
open("/cdrom/P5130043.JPG", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0555, st_size=8206, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)= 0x7feea7df3000
read(4, 0x7feea7df3000, 2048) = -1 EIO (Input/output error)
lseek(4, 0, SEEK_SET) = 0
mmap(NULL, 8206, PROT_READ, MAP_PRIVATE, 4, 0) = 0x7feea7df0000
close(4) = 0
munmap(0x7feea7df3000, 4096) = 0
--- SIGBUS (Bus error) @ 0 (0) ---
+++ killed by SIGBUS +++
Please register a SIGBUS handler during unmap

Bastien

Re: whishlist SIGBUS when EIO

Posted: 2011-04-21T08:33:13-07:00
by magick
We're not sure handling the SIGBUS signal is useful. The default is to core dump and exit. However, we'll add a handler since you requested it.

Re: whishlist SIGBUS when EIO

Posted: 2011-04-22T08:42:25-07:00
by broucaries
thanks for your patch but I will need to revert, it will not handle sigbus due to misalignement and will decrease the possibility to debug on sparc such fault

You should do something like this:
create a list of mmap file with mapped size
- catch sigbus, if addr (see sig_info_t) of fault is on the file mapped error on stderr and exit
- else restore sigbus to default handler and raise sigbus

Before that the list must be manipulated atomically (rcu in userspace is in this case a good option)

Bastien

Re: whishlist SIGBUS when EIO

Posted: 2011-04-22T09:12:33-07:00
by magick
Are there steps to reproduce this problem? We will come up with a patch once we can reliably reproduce the SIGBUS signal. Thanks.