Skip to content

libs/libc/stdlib: Raise SIGABRT in abort(). - #20634

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
casaroli:abort-sigabrt
Oct 14, 2026
Merged

xiaoxiang781216 merged 1 commit into
apache:masterfrom
casaroli:abort-sigabrt

Conversation

@casaroli

@casaroli casaroli commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

depends-on: [/pull/20661 apache/nuttx-apps/pull/3845]

Summary

abort() calls _exit() at once. A handler of SIGABRT never runs, and the comment above the function, which describes the POSIX behavior, is not true.

With CONFIG_ENABLE_ALL_SIGNALS, this PR unblocks and raises SIGABRT. If a handler returns, or SIGABRT is ignored, it restores the default action and raises SIGABRT again. _exit() stays as the last step, so abort() never returns.

Impact

abort() with CONFIG_ENABLE_ALL_SIGNALS. A SIGABRT handler now runs. The default action of SIGABRT ends the process, as before. Without CONFIG_ENABLE_ALL_SIGNALS there is no change.

Testing

qemu-armv8a:knsh, with this commit on a larger local branch. A test program sets the action of SIGABRT and calls abort(). Results after this PR:

  • a handler that writes a message and calls _exit(7): the message comes out, and the exit status is 7;
  • a handler that writes a message and returns: the message comes out, and the process ends;
  • SIG_IGN: the process ends.

In no case does abort() return. Before this PR, the handlers did not run, and the process exited with status 1 in all three cases.

Build: qemu-armv8a:nsh, qemu-armv8a:knsh and lm3s6965-ek:qemu-flat.

abort() called _exit() at once: a handler of SIGABRT never ran, and
the comment above the function, which describes the POSIX behavior,
was not true.

With CONFIG_ENABLE_ALL_SIGNALS, unblock and raise SIGABRT.  If a
handler returns, or SIGABRT is ignored, restore the default action and
raise it again.  _exit() stays as the last step.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
@github-actions github-actions Bot added Area: OS Components OS Components issues Size: S The size of the change in this PR is small labels Oct 13, 2026
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report

arduino-mega2560

  • flash: .data +16 B (+0.0%, 65,952 B / 262,144 B, total: 25% used)
  • sram: .data +16 B (+0.6%, 2,718 B / 8,192 B, total: 33% used)

esp32-devkitc

  • ROM: .dram0.data +16 B, .flash.rodata +12 B, .flash.text +768 B (+0.6%, 125,948 B / 4,194,272 B, total: 3% used)
  • dram0_0_seg: .dram0.data +16 B (+0.2%, 10,012 B / 180,736 B, total: 6% used)
  • drom0_0_seg: .flash.rodata +12 B (+0.1%, 13,472 B / 4,194,272 B, total: 0% used)
  • irom0_0_seg: .flash.text +768 B (+0.9%, 90,124 B / 3,342,304 B, total: 3% used)

hifive1-revb

  • flash: .data +8 B, .text +88 B (+0.1%, 84,348 B / 4,194,304 B, total: 2% used)
  • sram: .bss -16 B, .data +8 B (-0.2%, 3,956 B / 16,384 B, total: 24% used)

mirtoo

  • kseg0_progmem: .data +4 B, .text +12 B (+0.0%, 67,952 B / 131,072 B, total: 52% used)
  • kseg1_datamem: .data +4 B (+0.2%, 2,588 B / 32,256 B, total: 8% used)

qemu-armv8a

  • Code: .rodata +16 B, .text.abort +76 B, .text.lib_fwrite_unlocked +64 B, .text.nsh_cmdparm.constprop.0 +16 B, .text.nsh_parse_command +12 B (+0.1%, 347,772 B)
  • Data: .data.g_version +2 B (+0.0%, 77,476 B)

qemu-intel64

  • Code: .text +284 B (+0.0%, 8,682,796 B)

rx65n-rsk2mb

  • RAM: .data +4 B (+0.1%, 6,590 B / 262,144 B, total: 3% used)
  • ROM: .rodata +16 B, .text +192 B (+0.2%, 87,284 B / 2,097,152 B, total: 4% used)

s698pm-dkit

  • Code: .text +800 B (+0.2%, 375,472 B)

stm32-nucleo-f103rb

  • flash: .text +92 B (+0.3%, 34,752 B / 131,072 B, total: 27% used)

@casaroli casaroli closed this Oct 14, 2026
@casaroli casaroli reopened this Oct 14, 2026
@xiaoxiang781216
xiaoxiang781216 merged commit a60449b into apache:master Oct 14, 2026
76 of 105 checks passed
@github-actions

Copy link
Copy Markdown

🔗 Cross-repo PR dependencies

The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):

CI run: https://github.com/apache/nuttx/actions/runs/38551251861

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: OS Components OS Components issues Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants