Bug #13714
openWt::Htpp::Client: race condition while emitting headersReceived signal
100%
Description
In case postSignals_ == true and a linked session exists, emitHeadersReceived may be executed simultaneously with handleReadContent.
emitHeadersReceivedreads the whole message (i.e. it performs a copy of the message while emitting theheadersReceivedsignal)handleReadContentmay change the body of the message.
Hence, a race condition may occur, resulting in UB / a crash.
Possible solution
A possible solution is to copy the message already when posting emitHeadersReceived to the related session. An advantage of this solution is that the message provided as argument to the headersReceived signal does not contain a (partial) message body in all cases. Hence, the headersReceived signal is emitted with the exact same message independent of whether postSignals_ is true or false.
Updated by Matthias Van Ceulebroeck 6 months ago
- Target version set to 4.12.2
Perhaps ideally emitHeadersReceived() simply should not use the whole Message (meaning status, headers, and body), but only the status and actual headers.
Although that would change the API, and isn't really desired.
Updated by Romain Mardulyn 5 months ago
- Status changed from New to InProgress
- Assignee set to Romain Mardulyn
Updated by Romain Mardulyn 5 months ago
- Status changed from InProgress to Review
- Assignee deleted (
Romain Mardulyn)
Updated by Matthias Van Ceulebroeck 14 days ago
- Assignee set to Matthias Van Ceulebroeck
Updated by Matthias Van Ceulebroeck 9 days ago
- Status changed from Review to Implemented @Emweb
- Assignee changed from Matthias Van Ceulebroeck to Romain Mardulyn
- % Done changed from 0 to 100