On 10/28/2021 01:02, Sebastian Huber wrote:
On 27/10/2021 23:44, Kinsey Moore wrote:
+/*
+ * Exception handler. Map the exception class to SIGFPE, SIGSEGV
+ * or SIGILL for Ada or other runtimes.
+ */
+void _Exception_Raise_signal(
+  Internal_errors_Source source,
+  bool                   always_set_to_false,
+  Internal_errors_t      code
+)
+{
+  CPU_Exception_frame *ef;
+  int raise_signal;
+
+  if ( source != RTEMS_FATAL_SOURCE_EXCEPTION ) {
+    return;
+  }
+
+  ef = (rtems_exception_frame *) code;
+  raise_signal = _CPU_Exception_frame_get_signal( ef );
+  if ( raise_signal < 0 ) {
+    return;
+  }
+
+  /* Disable thread dispatch */
+  _CPU_Exception_disable_thread_dispatch();
+
+  /*
+   * While it would be preferable, the call to raise() cannot be deferred to a +   * post-switch action because it attempts to lock the post-switch action list +   * to add another item and the list is already locked for iteration. This
+   * causes a deadlock.
+   */
+  raise( raise_signal );

When you get an early exception (before RTEMS is initialized), then you get a double exception here or some sort of undefined behaviour.

I can use the system state for non-SMP systems and the Per_CPU state for SMP systems to ensure the current CPU is up for multitasking to prevent this functionality from executing in the case of an early exception. I find it a little odd that those are mutually exclusive (Per_CPU state isn't updated on non-SMP systems and overall system state isn't relevant for this on SMP systems).


Kinsey

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to