cshung commented on PR #3536: URL: https://github.com/apache/nuttx-apps/pull/3536#issuecomment-4733387274
Thanks for the suggestion. I looked into passing the register context through ucontext (the 3rd argument to the signal handler). Currently, `sig_deliver.c` passes NULL for ucontext on all three dispatch paths (lines 142, 164, 173). To pass the saved register context there, we'd need to address a few concerns: 1. **Protected/kernel builds**: `saved_regs` resides in kernel memory and cannot be directly exposed to userspace. Supporting ucontext in protected mode would require copying the context to the user stack before dispatch and copying it back after — adding unconditional overhead to every signal delivery, even when the handler doesn't use ucontext. 2. **NULL on synchronous signals**: `saved_regs` is only populated on the async path (interrupt → `arm_schedulesigaction`). For synchronous signals (e.g., `raise()`), it is NULL, so the handler cannot assume ucontext is always valid. 3. **Cross-architecture scope**: `sig_deliver.c` is arch-independent. Changing the ucontext passing behavior affects all architectures, which seems like a larger change than this test PR should drive. Given these constraints, I think keeping the `BUILD_FLAT` dependency is appropriate for now. The test validates the SP restoration fix using `nxsched_self()->xcp.saved_regs`, which is the simplest correct approach for flat builds. A proper ucontext implementation could be a separate effort if there's broader interest. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
