You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
std.debug should stop depending on getcontext() #23801
I believe the only current use of getcontext in the Zig library is in std.debug. From what I can tell, this code doesn't need a full ucontext_t (which includes a signal mask, floating point state, and a shadow stack). The existing debug code just needs the basic CPU registers. Perhaps just the mcontext_t register state would be sufficient?
I think moving away from getcontext() would make it easier to get the stack walking code working on other platforms (e.g., Android and OpenBSD don't provide a getcontext() at all, nor generally do freestanding and other targets). This also might make it simpler to get new platforms to support this debug code since they would just need a bit of arch-specific assembly to capture the basic registers.
Finally, the getcontext() API is "deprecated" (See https://man7.org/linux/man-pages/man3/getcontext.3.html: "POSIX.1-2008 removes these functions, citing portability issues, and recommending that applications be rewritten to use POSIX threads instead.") and has some hairy portability issues (it's a struct with embedded pointers that need to be fixed up when copied and its size can vary across C library versions and kernel versions).
Expected Behavior
std.debug uses locally defined assembly to capture register values, removing Zig's dependency on the getcontext() API.
To be clear, I intended for #23494 to be an incremental step towards what this issue is proposing. So, if this is something you feel like tackling, feel free to skip over the #23494 step.
Activity
alexrp commentedon May 5, 2025
cc #23494
alexrp commentedon May 6, 2025
To be clear, I intended for #23494 to be an incremental step towards what this issue is proposing. So, if this is something you feel like tackling, feel free to skip over the #23494 step.
std: rework/remove ucontext_t
std: rework/remove ucontext_t
std: rework/remove ucontext_t
std: rework/remove ucontext_t
std: rework/remove ucontext_t
std: rework/remove ucontext_t
std: rework/remove ucontext_t
std: rework/remove ucontext_t
std: rework/remove ucontext_t