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
fix: make httplib handlers more defensive during shutdown
Additional crash fixes for write_response_core SIGSEGV:
1. Exception handler now captures m_stopping by pointer and m_logger
by shared_ptr instead of capturing 'this'. This prevents accessing
invalid memory if the exception handler is called during shutdown.
2. Exception handler checks m_stopping flag first and returns early
with 503 if shutting down, avoiding any access to potentially
invalid state.
3. Route handlers now check m_stopping multiple times:
- At entry before any work
- After acquiring mutex (shutdown may have started while waiting)
- Before setting response content
4. Logging is now guarded by m_stopping checks to avoid accessing
the logger after it may have been invalidated.
The crash was occurring in write_response_core with a corrupted pointer
(0x0000002d000000ac), suggesting use-after-free of a std::function or
map during response writing. These changes minimize the window where
handlers can access Impl state during shutdown.
0 commit comments