bugfix/guard_page_and_ex_handle#13
Conversation
Agent-Logs-Url: https://github.com/Melnytskyi/fast_task/sessions/57e0a87f-741a-4a2b-b21f-6a61b611b899 Co-authored-by: Melnytskyi <[email protected]>
Agent-Logs-Url: https://github.com/Melnytskyi/fast_task/sessions/47d0fa60-d990-4aa9-95a7-48d5b37d8a91 Co-authored-by: Melnytskyi <[email protected]>
- Add fast_task::stack_overflow exception to include/exceptions.hpp
- Implement Linux x86_64 SIGSEGV handler in light_stack.cpp:
* Install per-thread alternate signal stack + process-wide sigaction
* On guard-page fault: mprotect to RW, set up return address from [RBP+8]
so the DWARF unwind chain is intact, redirect RIP to __stack_overflow_raise
* Restore PROT_NONE on guard page when recycling stacks (unlimited/limited_buffer)
- Add CMake fallback to valgrind stub headers when system valgrind not installed
- Add tests/stackfull/test_stackfull_guard.cpp (4 tests, all pass)
Agent-Logs-Url: https://github.com/Melnytskyi/fast_task/sessions/7235f5d5-bf5b-4d9b-860b-d2d013dbcf4e
Co-authored-by: Melnytskyi <[email protected]>
- Check mprotect() return value in signal handler; fall back to old handler on failure - Validate RBP is within valid (non-guard) stack bounds before dereferencing [RBP+8] - Check sigaltstack() return value; free alt-stack memory on failure - Discard stack in unlimited_buffer/limited_buffer if mprotect(PROT_NONE) fails Agent-Logs-Url: https://github.com/Melnytskyi/fast_task/sessions/7235f5d5-bf5b-4d9b-860b-d2d013dbcf4e Co-authored-by: Melnytskyi <[email protected]>
…ow recovery - Add FAST_TASK_GUARD_PAGE_COUNT cmake option (default 1); passes FT_GUARD_PAGE_COUNT to the library so guard page size is configurable at build time; 0 disables mprotect - Remove stack_overflow exception type from exceptions.hpp - Linux light_stack: remove SIGSEGV handler machinery (handler, alt-stack, sigaction); make __install_signal_handler_mem a no-op; drive guard_page_size from FT_GUARD_PAGE_COUNT; guard mprotect(PROT_NONE) in create_stack with #if FT_GUARD_PAGE_COUNT > 0; remove mprotect restoration from unlimited_buffer / limited_buffer - Windows light_stack: drive guard_page_size from FT_GUARD_PAGE_COUNT; guard PAGE_GUARD commit with #if FT_GUARD_PAGE_COUNT > 0 - test_stackfull_guard: remove stack-overflow tests; keep 2 exception-callback tests Agent-Logs-Url: https://github.com/Melnytskyi/fast_task/sessions/463eb9a4-b8be-4088-becb-33ec6fdfbd0e Co-authored-by: Melnytskyi <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR simplifies stack guard handling by moving away from stack-overflow recovery and adds configurable guard-page sizing, Valgrind header fallbacks, exception-callback coverage, and an abort option for closing bind-only executors.
Changes:
- Adds
FAST_TASK_GUARD_PAGE_COUNTand applies guard-page sizing on Linux/Windows stacks. - Adds bundled minimal Valgrind header stubs for builds without system Valgrind headers.
- Adds exception callback tests and extends bind-only executor close API with
abort_tasks.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
CMakeLists.txt |
Adds guard-page count definition and Valgrind stub include fallback. |
include/task/scheduler.hpp |
Extends close_bind_only_executor with abort_tasks. |
src/tasks/_internal.hpp |
Stores binded executor abort-on-close state. |
src/tasks/classes/task/scheduler.cpp |
Propagates abort-on-close state while closing bind-only executors. |
src/tasks/scheduler.cpp |
Handles in-place exception callbacks and aborts queued binded tasks on close. |
src/tasks/util/light_stack.cpp |
Applies configurable guard-page behavior and removes Linux signal-handler recovery. |
tests/stackfull/CMakeLists.txt |
Registers the new stackfull guard test target. |
tests/stackfull/test_stackfull_guard.cpp |
Adds portable exception-callback and RAII unwinding tests. |
third_party/valgrind-stubs/valgrind/memcheck.h |
Adds minimal Memcheck no-op macros. |
third_party/valgrind-stubs/valgrind/valgrind.h |
Adds minimal Valgrind no-op macros. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/Melnytskyi/fast_task/sessions/1508b0a8-36ab-4951-93df-4db9191e6658 Co-authored-by: Melnytskyi <[email protected]>
Agent-Logs-Url: https://github.com/Melnytskyi/fast_task/sessions/1508b0a8-36ab-4951-93df-4db9191e6658 Co-authored-by: Melnytskyi <[email protected]>
Implemented the requested review-thread fixes in commits c2a5790 and b4c6989: abort-on-close now correctly handles queued bind-worker tasks (without rescheduling when aborting), aborted tasks now mark Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot change the stack allocation to allocate size + guard_pages_size instead of just size to keep the behavior as expected regardless of the library configuration (big guard page setting could set whole stack as guard page and the coroutine couldn't start) |
Agent-Logs-Url: https://github.com/Melnytskyi/fast_task/sessions/c5f400fb-8b0b-4f7e-8b0d-1be09730581f Co-authored-by: Melnytskyi <[email protected]>
Fixed in commit |
Uh oh!
There was an error while loading. Please reload this page.