This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Don't ask for QOS_CLASS_UNSPECIFIED queue in TestQueues
ClosedPublic

Authored by teemperor on Aug 19 2020, 6:14 AM.

Details

Summary

TestQueues is curiously failing for me as my queue for QOS_CLASS_UNSPECIFIED
is named "Utility" and not "User Initiated" or "Default". While debugging, this
I noticed that this test isn't actually using this API right from what I understand. The API documentation
for dispatch_get_global_queue specifies for the parameter: "You may specify the value
QOS_CLASS_USER_INTERACTIVE, QOS_CLASS_USER_INITIATED, QOS_CLASS_UTILITY, or QOS_CLASS_BACKGROUND."

QOS_CLASS_UNSPECIFIED isn't listed as one of the supported values. swift-corelibs-libdispatch
even checks for this value and returns a DISPATCH_BAD_INPUT. The
libdispatch shipped on macOS seems to also check for QOS_CLASS_UNSPECIFIED and seems to
instead cause a "client crash", but somehow this doesn't trigger in this test and instead we just
get whatever queue

This patch just removes that part of the test as it appears the code is just incorrect.

Diff Detail

Event Timeline

teemperor created this revision.Aug 19 2020, 6:14 AM
teemperor requested review of this revision.Aug 19 2020, 6:14 AM

Some links to the swift sources:

  1. The dispatch_get_global_queue source: https://github.com/apple/swift-corelibs-libdispatch/blob/f7a0cbb/src/init.c#L365
  2. This passes the input QoS to _dispatch_qos_from_queue_priority : https://github.com/apple/swift-corelibs-libdispatch/blob/f7a0cbb761e49df0b1a114b0537ae03aacf2519e/src/shims/priority.h#L173
  3. Which then calls _dispatch_qos_from_qos_class which defines DISPATCH_QOS_UNSPECIFIED as an error value: https://github.com/apple/swift-corelibs-libdispatch/blob/f7a0cbb761e49df0b1a114b0537ae03aacf2519e/src/shims/priority.h#L143
  4. That all returns and when the calculated QoS is "UNSPECIFIED" we should hit the error case here and return "BAD_INPUT": https://github.com/apple/swift-corelibs-libdispatch/blob/f7a0cbb/src/init.c#L381
jasonmolenda accepted this revision.Aug 24 2020, 12:10 PM

LGTM, that call to dispatch_get_global_queue QOS_CLASS_UNSPECIFIED does not look valid.

This revision is now accepted and ready to land.Aug 24 2020, 12:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2020, 11:14 AM