Re: SIGSEGV catching

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 10, 2002 at 08:55:33AM +0200, Emilio Riva wrote:
> Is there a way to safely catch a SIGSEGV signal? I mean, recovering the
> read/write error "bypassing" the bad code instruction?

POSIX states that any actions the process takes after being sent a
SIGSEGV is undefined. This means that the process's behavior after being
sent a SIGSEGV can change from kernel version to kernel version, and OS
to OS. Whatever you wind up doing would not be very portable.

> In alternative: is there a way, for a user process perspective, to
> understand if a pointer points to an heap address space or to a
> stack/anything other address space?

Keep track of what you assigned to the pointer in the first place? :)
You could compare the pointer value against the entries in
/proc/pid/maps. But that would be portable only among linux systems.

Since userspace defines its own heap through the brk(2) and sbrk(2)
syscalls, and malloc(3)ed memory can be done through mmap(2), it ought
to be doable to keep track of these two sets of memory usage; keeping
track of the stack in userspace might be more difficult.

Good luck

-- 
http://sardonix.org/

Attachment: pgp00075.pgp
Description: PGP signature


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux