From a5adb667089c0f5345bbd4908eb9263101671cd0 Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Tue, 4 Aug 2026 17:56:40 +0200 Subject: [PATCH] device: add kernel-mode crash signatures for user task faults In kernel builds a faulting user task is killed while the kernel keeps running and the prompt returns, so the console message is the only crash evidence; such faults were reported as command timeouts. Register the fault messages as SEGFAULT signatures: - 'Segmentation fault in' (risc-v) - 'PANIC: Unhandled user exception' (arm64) Signed-off-by: raiden00pl Assisted-by: Claude Code --- src/ntfc/device/nuttx.py | 7 +++++++ tests/device/test_nuttx.py | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/ntfc/device/nuttx.py b/src/ntfc/device/nuttx.py index a12cc94..6d40ef9 100644 --- a/src/ntfc/device/nuttx.py +++ b/src/ntfc/device/nuttx.py @@ -51,6 +51,13 @@ class DeviceNuttx(OSCommon): b"up_dump_register", b"dump_tasks", ], + # kernel-mode (CONFIG_BUILD_KERNEL) user task faults: the kernel + # kills the offending task and keeps running, so the console + # message is the only crash evidence + CrashType.SEGFAULT: [ + b"Segmentation fault in", + b"PANIC: Unhandled user exception", + ], } _PANIC_CHAR = r"/" diff --git a/tests/device/test_nuttx.py b/tests/device/test_nuttx.py index dd90df5..0275236 100644 --- a/tests/device/test_nuttx.py +++ b/tests/device/test_nuttx.py @@ -43,6 +43,22 @@ def test_device_nuttx_init(): assert CrashType.ASSERTION in sigs assert all(isinstance(v, list) for v in sigs.values()) + # kernel-mode user task faults kill only the task; the console + # message is the only crash evidence + assert CrashType.SEGFAULT in sigs + assert b"Segmentation fault in" in sigs[CrashType.SEGFAULT] + assert b"PANIC: Unhandled user exception" in sigs[CrashType.SEGFAULT] + + # real rv-virt knsh64 console output is classified as SEGFAULT + from ntfc.device.state import DeviceStateManager + + mgr = DeviceStateManager(crash_signatures=sigs) + line = ( + b"[ 2.966000] riscv_fault_handler: " + b"Segmentation fault in getprime (PID 4: getprime)" + ) + assert mgr._detect_crash_type(line) is CrashType.SEGFAULT + config.kv_check.return_value = 0 assert d.panic_char == "" config.kv_check.return_value = 1