[lkml]   [2001]   [Sep]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: mmap successed but SIGBUS generated on access
Andrew V. Samoilov wrote:
> I have bad CD-R with a some number of unreadable files.
> Then user-space program use mmap system it returns ok but any
> attempt to access a memory pointed by this system call finishes
> with SIGBUS. So Midnight Commander internal file viewer faults.

You can get the same problem even without read errors with some
configurations of NFS. (root mmaps a file owned by someone else, but
cannot read the file due to `root_squash' on server).

> This error is 100 % reproduceable at 2.2.19 and 2.4.2 kernels.

It's not an error, it's standard behaviour.

> Is there any way to detect such problem in user-space without signal
> handlers ?

I don't think there is any way without a signal handler.

It is possible to do something useful with a signal handler sometimes.
For example, you can mmap() a zero page into the offending page once
you've got the fault address, or read() a zero page if you did
MAP_PRIVATE (this produces fewer VMAs), set a flag, and let the program
continue until it checks the flag and aborts the parsing or whatever
operation it's doing.

Unfortunately I don't think the signal handler's si_errno is set
properly to indicate the error. So another thing to try is read() of
the offending page, to get a useful error code. (And if the read
succeeds, that's ok because you did it at the correct address so the
program can proceed anyway).

Fwiw, unfortunately not all versions of the kernel, or all
architectures, set si_addr properly for SIGBUS.

-- Jamie
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:03    [W:0.024 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site