Closed Mis1eader-dev closed 1 year ago
On a clean project it worked as expected for the filter, however, in an already established project it fails the following assert:
drogon::IOThreadStorage<C>::ValueType& drogon::IOThreadStorage<C>::getThreadData() [with C = std::unordered_map<std::__cxx11::basic_string<char>, std::shared_ptr<drogon::HttpResponse> >; drogon::IOThreadStorage<C>::ValueType = std::unordered_map<std::__cxx11::basic_string<char>, std::shared_ptr<drogon::HttpResponse> >]: Assertion `idx < storage_.size()' failed.
We'll see where this goes.
Update: Apparently it doesn't crash on req
accesses, it occurs on fccb()
Found the bug, it is caused by "locations" config entry, see the reproduceable example 29b188c @an-tao
Update: Running it in debug mode, it crashes on both a controller registered with a filter, and "locations" defined filters.
It appears FilterChainCallback&& fccb
is the cause, no issues if FilterCallback&& fcb
is called within the thread.
Area of the crash in question is lib/inc/drogon/IOThreadStorage.h - getThreadData and lib/src/HttpAppFrameworkImpl.h - getCurrentThreadIndex
Describe the bug Spinning up a thread within
doFilter
and capturing theHttpRequestPtr
parameter by value leads to a segmentation fault. This isn't the case with normal http request handlersasyncHandleHttpRequest
, it works fine with them.To Reproduce Steps to reproduce the behavior:
req
by value.req->something
.Expected behavior It should stay alive until
fcb
orfccb
are called.Desktop (please complete the following information):
Additional context Reason for this need is to handle IO bound synchronous calls within these threads.