Skip to content

QAbstractFileEngine: fix UB (data race) on qt_file_engine_handlers_in_use

While all writers of the variable hold fileEngineHandlerMutex for writing, the qt_custom_file_engine_handler_create() function checks the value before entering a fileEngineHandlerMutex read-side critical section, thereby causing a C++11 data race.

Fix by making the variable atomic. Interestingly enough, relaxed atomic operations suffice here, since the actual synchronization happens in read- and write-side critical sections, and if qt_file_engine_handlers_in_use is wrong w.r.t. to the actual list, the critical sections will still work. We just mustn't cause UB by reading and writing to a simple bool without proper synchronization.

Pick-to: 6.2 5.15

Change-Id: I30469504cdbc90e2ab27125181e53d74305f13fd

Reviewed-by: Thiago Macieira

Reviewed-by: Fabian Kosmale

(cherry picked from commit 53647110)

Merge request reports