nuttx/sched/misc
chenzhaoxiang 14fb39a6cd sched/misc: fix incomplete data emission in coredump elf_emit function
The elf_emit() function in coredump.c was only checking for negative returnvalues
from lib_stream_puts() to detect write failures. However, lib_stream_puts()can return 0
to indicate that no bytes were written (e.g., due to stream full,end-of-file, or other
non-error conditions that prevent data writing).

This oversight meant that cases where lib_stream_puts() returned 0 would bypassthe error handling,
leading to incomplete data emission in the core dump withoutany failure indication.
The loop would continue attempting to write the remainingdata, resulting in partial or corrupted core dump files.

This fix modifies the condition from ret < 0 to ret <= 0 to:

1. Catch both error conditions (negative return values) and zero-byte writes.
2. Immediately break the write loop and propagate the failure, ensuring the core
   dump process correctly aborts when data cannot be written.

This change improves the reliability of core dump generation by ensuring allfailed or
incomplete write attempts are properly handled, preventing corruptedcore dump files.

Signed-off-by: chao an <anchao.archer@bytedance.com>
2026-02-26 14:44:16 +01:00
..
assert.c sched/spinlock: Call spinlock nopreempt when need disable context switch. 2026-01-27 19:33:58 +08:00
CMakeLists.txt coredump:Move coredump to sched/misc 2024-10-12 12:29:06 +08:00
coredump.c sched/misc: fix incomplete data emission in coredump elf_emit function 2026-02-26 14:44:16 +01:00
coredump.h coredump:Move private functions to internal header files 2024-10-12 12:29:06 +08:00
deadlock.c Clean up the nxmutex library 2025-05-08 16:00:05 +08:00
Make.defs coredump:Move coredump to sched/misc 2024-10-12 12:29:06 +08:00
panic_notifier.c spinlock: Fix compilation error with atomic.h. 2025-06-25 22:13:00 +08:00
reboot_notifier.c userspace: Exclude nuttx/arch.h 2024-11-01 16:59:37 +08:00