Skip to content

QThread: fix UB (invalid enum value) on Private::Priority

The Unix code stores an additional flag, ThreadPriorityResetFlag, in
the Policy enum, but ubsan does not approve:

  qthread_unix.cpp:303:30: runtime error: load of value 2147483648, which is not a valid value for type 'Priority'
  qthread_unix.cpp:304:75: runtime error: load of value 2147483648, which is not a valid value for type 'Priority'

Fix by making the variable of std::underlying_type_t<Priority>.

The masking and unmasking code can now be simplified, too.

In the Windows version, replace some switch targets with equivalent
ones to keep -Wswitch-like warnings, though I hasten to note that both
switches use a default case, so have anyway implicitly disabled said
warning.

Pick-to: 6.3 6.2 5.15
Change-Id: Ie4ea7d05e2928d2755ad12d36535197f85493191
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
(cherry picked from commit 591a35d6fd9fa4f14ca1ac6a568673e2a2da0f60)

asturmlechner 2022-01-04: Resolve conflict in qthread_unix.cpp with dev branch commit cffc667a

I believe this is correct, but please check considering the necessary conflict resolution.

Merge request reports

Loading