Crash in active Wt::Http::Client destructor if started outside WApplication
The destructor of
Http::Client calls abort which asynchronously aborts the http request.
impl->hasServer() is false, a pointer to the Client's
impl_ member is passed to asyncStop; see https://github.com/emweb/wt/blob/master/src/Wt/Http/Client.C#L850
This member will be destructed briefly after this call, as abort is called from inside the
However, in the asynchronously executed stop function (https://github.com/emweb/wt/blob/master/src/Wt/Http/Client.C#L178), this (possibly) dangling pointer will be dereferenced.
Note that this code was added in commit 9c44b4e3c2 with commit message "Fixed possible race condition when resetting impl_ of HTTP Client". However it is unclear to me which in which scenario the mentioned race condition is avoided.
Steps to reproduce the issue¶
- Start a new thread
- Start a (long running) http request using
- Destruct the
Wt::Http::Clientobject (before the http request is finished.