immobiliare / RealHTTP

🌀swift async http client - fast, lightweight, type-safe
MIT License
282 stars 28 forks source link

Thread Safety Issue accessing to HTTPDataLoader (#2) #48

Closed aetherealtech closed 2 years ago

aetherealtech commented 2 years ago

Bug Report

Q A
BC Break yes
Version 1.4.0

Summary

We have seen intermittent crashes in HTTPDataLoader.fetch, while writing a response to the dataLoadersMap dictionary. A cursory inspection of the code in HTTPDataLoader makes it look like this dictionary is not protected by atomic access, but it is being accessed (both read from and written to) from multiple threads. The access is inside an operation added to the session's delegate queue, but this queue is concurrent. We believe this may be why we are seeing intermittent crashes in this area.

Screen Shot 2022-05-23 at 4 33 51 PM

malcommac commented 2 years ago

We made some improvements with #45 but this improves the safety of the loader's dictionary in a multi-threading environment. Thank you very much.

aetherealtech commented 2 years ago

Thanks for the quick turnaround!