Skip to content

[SR-16008] Crash in NativeSet.subtracting in Swift 5.6 #58269

@bjhomer

Description

@bjhomer
Previous ID SR-16008
Radar rdar://problem/90450460
Original Reporter @bjhomer
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Swift 5.6 (Xcode 13.3 RC)

Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee @eeckstein
Priority Medium

md5: 674f6e7f2c1d562dd01cd5928d2907d0

Issue Description:

We've recently upgraded to Swift 5.6 (with Xcode 13.3), and we're seeing reports of crashes in NativeSet.subtracting. We haven't changed any of this code in months; the only change is that we're now building with Swift 5.6.

I see that there were some changes to NativeSet.subtracting in Swift 5.6, so I'm wondering if our crashes are related to these changes.

Our code looks like this:

// These sets could have 1000s of items in them. Or zero.
// Depends on user behavior.
let a: Set<String> = potentiallyLargeSetOfStrings()
let b: Set<String> = anotherLargeSetOfStrings()
let itemsNoLongerUsed = b.subtracting(a) // This line is crashing

Full crash logs attached below, but the relevant part looks like this:

 Thread 11 name:
 Thread 11 Crashed:
 0 ??? 0x0000000000000000 0x0 + 0
 1 DOCore 0x00000001059f477c $ss10_NativeSetV11subtractingyAByxGqd__7ElementQyd__RszSTRd__lFSS_ShySSGTg5 + 8 (<compiler-generated>:0)
 2 DOCore 0x00000001059f477c $sSh12_subtractingyShyxGqd__7ElementQyd__RszSTRd__lFSS_ShySSGTg5 + 8 (<compiler-generated>:0)

swift-demangle reports those frames as this:

1   generic specialization <Swift.String, Swift.Set<Swift.String>> of Swift._NativeSet.subtracting<A where A == A1.Element, A1: Swift.Sequence>(A1) -> Swift._NativeSet<A>

2   generic specialization <Swift.String, Swift.Set<Swift.String>> of Swift.Set._subtracting<A where A == A1.Element, A1: Swift.Sequence>(A1) -> Swift.Set<A>

I have not been able to reproduce this crash locally yet, but we've got a bunch of reports from 8 beta testers in just a few hours, so it seems like it's a reasonably common thing to hit, and not likely dependent on having very particularly crafted set.

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions