#2263 assigned defect

POSIX signal handler can cause stack overflow when blocked

Reported by: Daniel Hellstrom Owned by: Needs Funding
Priority: normal Milestone: Indefinite
Component: unspecified Version: 4.10
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description

The psxalarm test brought it to my attention. The psxalarm signal handler causes a stack overflow to happen when printf() is called from the handler.

It can be triggered on UP and SMP LEON3 or NGMP systems, more frequent on a slow UART. It also seems easier to trigger the case on systems with short console UART FIFO depth.

If the signal handler contains a blocking call it seems that when the task executing the handler is woken up again another stack frame with the same POSIX signal handler is called. Now that handler will make the same blocking call, when woken up again another stack frame is added and so on. Eventually a stack overflow occurs.

This behaviour seems to be present since 4.10 at least.

Change History (8)

comment:1 Changed on Feb 12, 2015 at 9:02:11 AM by Sebastian Huber

This is a known problem (or feature?) of the signal implementation. In case you call _Thread_Dispatch() in a signal handler, this is a recursion.

comment:2 Changed on Feb 12, 2015 at 2:06:29 PM by Gedare

If we don't fix it, then it should be documented.

comment:3 Changed on Feb 12, 2015 at 2:16:20 PM by Sebastian Huber

Its possible to fix this, but it has absolutely no priority for me. The signals are a questionable concept in general on a real-time system.

comment:4 Changed on Feb 12, 2015 at 2:41:25 PM by Gedare

A lot of embedded systems use signals pervasively in component-based software frameworks. Whether or not they achieve hard real-time guarantees is questionable. However, POSIX compliance should not mean RTEMS provides features that are not properly documented in how to use them.

I appreciate the lack of priority for fixing this. We should document it (somewhere related to signals in the POSIX manual) and move on for now, but leave the ticket open and bump the milestone to 5.0.

comment:5 Changed on Mar 2, 2015 at 8:50:26 PM by Gedare

Milestone: 4.115.0

bump milestone

comment:6 Changed on Mar 2, 2015 at 8:50:59 PM by Gedare

Milestone: 5.04.11.1

adjust from 5.0 to 4.11.1

comment:7 Changed on Jan 26, 2017 at 7:16:00 AM by Sebastian Huber

Milestone: 4.11.14.11.2

comment:8 Changed on Feb 15, 2017 at 1:14:08 PM by Sebastian Huber

Milestone: 4.11.2Indefinite
Owner: set to Needs Funding
Status: newassigned
Note: See TracTickets for help on using tickets.