Discussion:
How memory access violation should be handled ?
Hesham Moustafa
2013-07-04 02:40:53 UTC
Permalink
Hi,

What's the best way(s) to handle memory exceptions that result from memory
access and permission violations ? for example, what should happen if an
area of memory set to be read only and a thread tried to write data into
this area ? Currently I am using it in debugging purpose to monitor
exception handling and get some details, bit what should happen in practice
?

Regards,
Hesham
Sebastian Huber
2013-07-04 07:31:17 UTC
Permalink
Post by Hesham Moustafa
Hi,
What's the best way(s) to handle memory exceptions that result from memory
access and permission violations ? for example, what should happen if an area
of memory set to be read only and a thread tried to write data into this area ?
Currently I am using it in debugging purpose to monitor exception handling and
get some details, bit what should happen in practice ?
The systems should end up in an exception which should call

rtems_fatal(
RTEMS_FATAL_SOURCE_EXCEPTION,
(rtems_fatal_code) exception_frame_pointer
);

This is all a single address space operating system can do. The fatal
extensions can then deal with the error.
--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber-L1vi/***@public.gmane.org
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
Peter Dufault
2013-07-04 19:33:27 UTC
Permalink
Post by Sebastian Huber
Post by Hesham Moustafa
Hi,
What's the best way(s) to handle memory exceptions that result from memory
access and permission violations ? for example, what should happen if an area
of memory set to be read only and a thread tried to write data into this area ?
Currently I am using it in debugging purpose to monitor exception handling and
get some details, bit what should happen in practice ?
The systems should end up in an exception which should call
rtems_fatal(
RTEMS_FATAL_SOURCE_EXCEPTION,
(rtems_fatal_code) exception_frame_pointer
);
This is all a single address space operating system can do. The fatal
extensions can then deal with the error.
--
It would be useful to be able to get it into a signal handler using sigaction for SIGBUS or SIGSEGV.

Peter
-----------------
Peter Dufault
HD Associates, Inc. Software and System Engineering
Sebastian Huber
2013-07-05 07:23:08 UTC
Permalink
Post by Peter Dufault
Post by Sebastian Huber
Post by Hesham Moustafa
Hi,
What's the best way(s) to handle memory exceptions that result from memory
access and permission violations ? for example, what should happen if an area
of memory set to be read only and a thread tried to write data into this area ?
Currently I am using it in debugging purpose to monitor exception handling and
get some details, bit what should happen in practice ?
The systems should end up in an exception which should call
rtems_fatal(
RTEMS_FATAL_SOURCE_EXCEPTION,
(rtems_fatal_code) exception_frame_pointer
);
This is all a single address space operating system can do. The fatal
extensions can then deal with the error.
--
It would be useful to be able to get it into a signal handler using sigaction for SIGBUS or SIGSEGV.
You can add an initial extension and do with this error whatever you want. The
initial fatal extensions have a very limited execution environment requirement:

http://www.rtems.org/onlinedocs/doxygen/cpukit/html/group__ScoreIntErr.html#ga68b70f90a5add34b8c83d206f8b53ee9

I don't think it is a good idea to add signals here as a default since they
require much more infrastructure.
--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber-L1vi/***@public.gmane.org
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
Joel Sherrill
2013-07-04 13:19:15 UTC
Permalink
Will this include enough information to know what type of access violation, the thread, the faulting address, and the instruction address?

It is a fatal error and it is a set of standard ones so maybe the master list can be extended.

Put yourself in the programmer's position. You want enough information to fix it.
Post by Hesham Moustafa
Hi,
What's the best way(s) to handle memory exceptions that result from memory
access and permission violations ? for example, what should happen if an area
of memory set to be read only and a thread tried to write data into this area ?
Currently I am using it in debugging purpose to monitor exception handling and
get some details, bit what should happen in practice ?
The systems should end up in an exception which should call

rtems_fatal(
RTEMS_FATAL_SOURCE_EXCEPTION,
(rtems_fatal_code) exception_frame_pointer
);

This is all a single address space operating system can do. The fatal
extensions can then deal with the error.

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber-L1vi/***@public.gmane.org
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
Sebastian Huber
2013-07-04 13:27:58 UTC
Permalink
Post by Joel Sherrill
Will this include enough information to know what type of access violation, the thread, the faulting address, and the instruction address?
In case the source is RTEMS_FATAL_SOURCE_EXCEPTION the code is a pointer to
rtems_exception_frame also known as CPU_Exception_frame. So the information is
CPU specific at the moment.

The thread is _Thread_Executing.
--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber-L1vi/***@public.gmane.org
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
Loading...