whishlist SIGBUS when EIO

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
broucaries
Posts: 467
Joined: 2008-12-21T11:51:10-07:00

whishlist SIGBUS when EIO

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: whishlist SIGBUS when EIO

Post 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.
broucaries
Posts: 467
Joined: 2008-12-21T11:51:10-07:00

Re: whishlist SIGBUS when EIO

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: whishlist SIGBUS when EIO

Post 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.
Post Reply