Re: SIGSEGV handler Question



"LaBird" <bowlcheflung@xxxxxxxxx> writes:

Hi,

<gil_hamilton@xxxxxxxxxxx>
???????:1157032545.274513.144910@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
LaBird wrote:
I'd like to ask if it is possible to write a signal handler to capture
SIGSEGV, and handles the fault by changing the virtual address the
program
is accessing instead? For example, if a read to VM address 0x12340000
causes
a SIGSEGV, instead of changing the memory protection of 0x12340000 to
readable or perform a memory mapping on this address inside the signal
handler, is it possible to change the VM address to be accessed to, say
0x56780000 inside the handler (assume 0x56780000 is mapped and is
readable)?

It's possible - barely - but it's a really bad idea and would be
fiendishly hard to implement (especially with any significant
generality). What exactly are you trying to accomplish?

Actually it's one of the ways I think of about the implementation of a
Distributed Shared Memory (DSM)... the 0x12340000 will be the original
(fixed) position of a shared object, and 0x56780000 is the (temporary)
address of a local copy of that object.

I don't see how it could be done in any real useful sense -- in order
to avoid crippling performance delays, you'd have to change not just the
one memory reference, but also the code that generated the memory
reference, and any other code that wound up calculating the same
address in any way whatever (the last of which isn't even
theoretically possible).
--
Joseph J. Pfeiffer, Jr., Ph.D. Phone -- (505) 646-1605
Department of Computer Science FAX -- (505) 646-1002
New Mexico State University http://www.cs.nmsu.edu/~pfeiffer
.



Relevant Pages

  • Re: will the memory allocated by malloc get released when program exits?
    ... Always free all memory you allocate. ... Let's examine for a moment how one can come across a SIGSEGV: ... why one should not allocate or free memory within a SIGSEGV handler. ... But it's the undefined behavior that's the underlying problem. ...
    (comp.lang.c)
  • Interrupt handler seems not to be called in GNAT 3.15p
    ... When accessing memory, I might not have access to some memory location. ... I can see SIGSEGV being raised. ... it is not passed to my interrupt handler, ...
    (comp.lang.ada)
  • Re: Serious compatibility breakage in -current.
    ... more POSIXly correct, provided that he interpreted POSIX correctly; ... Write attempts to memory that was mapped without write access, ... References to unmapped addresses shall result in a SIGSEGV signal. ... shall result in a SIGBUS signal. ...
    (freebsd-current)
  • Re: SIGSEGV handler Question
    ... SIGSEGV, and handles the fault by changing the virtual address the ... readable or perform a memory mapping on this address inside the signal ... Distributed Shared Memory... ...
    (comp.os.linux.development.apps)
  • Re: Serious compatibility breakage in -current.
    ... Write attempts to memory that was mapped without write access, ... References to unmapped addresses shall result in a SIGSEGV signal. ... shall result in a SIGBUS signal. ... So you are breaking compatibility for no good reason. ...
    (freebsd-current)