swiftlang / swiftlang/swift-corelibs-libdispatch

[SR-11813] DispatchGroup not Equatable on Linux

Open
#613 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug libdispatch Linux
Dominant language
C
Stars
2.6k
Forks
496
Avg merge
2d 6h
Merged PRs (30d)
3

Description

Previous ID SR-11813
Radar rdar://problem/57348907
Original Reporter jfilling (JIRA User)
Type Bug

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s libdispatch
Labels Bug
Assignee None
Priority Medium

md5: d0c67de0f8ac39b14364c95a29dd21f6

Issue Description:

It appears that DispatchGroups are Equatable on MacOS, but not on Linux.

Using the following simple test program (as foo.swift):

import Dispatch
let g1 = DispatchGroup()
let g2 = DispatchGroup()
if g1 == g2 {
    print("groups are equal")
}
else {
    print("groups are NOT equal")
}

On MacOS:

$ swift --version
Apple Swift version 5.1.2 (swiftlang-1100.0.278 clang-1100.0.33.9)
Target: x86_64-apple-darwin18.7.0
$ swift foo.swift 
groups are NOT equal

On Linux (Ubuntu 18.04):

$ swift --version                                                                                                                                                                                                                                                           
Swift version 5.1 (swift-5.1.2-RELEASE)
Target: x86_64-unknown-linux-gnu
$ swift foo.swift                                                                                                                                                                                                                                                           
foo.swift:8:7: error: binary operator '==' cannot be applied to two 'DispatchGroup' operands
if g1 == g2 {
   ~~ ^  ~~
foo.swift:8:7: note: overloads for '==' exist with these partially matching parameter lists: ((), ()), ((A, B), (A, B)), ((A, B, C), (A, B, C)), ((A, B, C, D), (A, B, C, D)), ((A, B, C, D, E), (A, B, C, D, E)), ((A, B, C, D, E, F), (A, B, C, D, E, F)), (Any.Type?, Any.Type?), (AnyHashable, AnyHashable), (AnyIndex, AnyIndex), (AnyKeyPath, AnyKeyPath), (Array<Element>, Array<Element>), (ArraySlice<Element>, ArraySlice<Element>), (Bool, Bool), (Character, Character), (ClosedRange<Bound>, ClosedRange<Bound>), (ClosedRange<Bound>.Index, ClosedRange<Bound>.Index), (CodingUserInfoKey, CodingUserInfoKey), (CollectionDifference<ChangeElement>, CollectionDifference<ChangeElement>), (CollectionDifference<ChangeElement>.Change, CollectionDifference<ChangeElement>.Change), (CollectionDifference<ChangeElement>.Index, CollectionDifference<ChangeElement>.Index), (ContiguousArray<Element>, ContiguousArray<Element>), (Dictionary<Key, Value>.Index, Dictionary<Key, Value>.Index), (Dictionary<Key, Value>.Keys, Dictionary<Key, Value>.Keys), (DispatchQoS, DispatchQoS), (DispatchTime, DispatchTime), (DispatchTimeInterval, DispatchTimeInterval), (DispatchWallTime, DispatchWallTime), (EmptyCollection<Element>, EmptyCollection<Element>), (FlattenSequence<Base>.Index, FlattenSequence<Base>.Index), (FloatingPointClassification, FloatingPointClassification), (FloatingPointRoundingRule, FloatingPointRoundingRule), (FloatingPointSign, FloatingPointSign), (Int, Int), (Int16, Int16), (Int32, Int32), (Int64, Int64), (Int8, Int8), (LazyPrefixWhileSequence<Base>.Index, LazyPrefixWhileSequence<Base>.Index), (ManagedBufferPointer<Header, Element>, ManagedBufferPointer<Header, Element>), (Mirror.DisplayStyle, Mirror.DisplayStyle), (Never, Never), (ObjectIdentifier, ObjectIdentifier), (OpaquePointer, OpaquePointer), (Range<Bound>, Range<Bound>), (Result<Success, Failure>, Result<Success, Failure>), (ReversedCollection<Base>.Index, ReversedCollection<Base>.Index), (Self, Other), (Self, RHS), (Set<Element>, Set<Element>), (Set<Element>.Index, Set<Element>.Index), (String, String), (String.Index, String.Index), (UInt, UInt), (UInt16, UInt16), (UInt32, UInt32), (UInt64, UInt64), (UInt8, UInt8), (Unicode.CanonicalCombiningClass, Unicode.CanonicalCombiningClass), (Unicode.GeneralCategory, Unicode.GeneralCategory), (Unicode.NumericType, Unicode.NumericType), (Unicode.Scalar, Unicode.Scalar), (Unicode.UTF32, Unicode.UTF32), (UnicodeDecodingResult, UnicodeDecodingResult), (Wrapped?, Wrapped?), (Wrapped?, _OptionalNilComparisonType), ([Key : Value], [Key : Value]), (_OptionalNilComparisonType, Wrapped?), (_UIntBuffer<Element>.Index, _UIntBuffer<Element>.Index), (_ValidUTF8Buffer.Index, _ValidUTF8Buffer.Index)
if g1 == g2 {
      ^

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the foo.swift reproducer in the issue and compare DispatchGroup equality behavior on Linux with the documented macOS result. Then inspect the libdispatch component for the DispatchGroup API and its platform-specific implementation. Done means the same comparison compiles and produces the expected result on Linux.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, swift
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.