swiftlang / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. This fork is used to manage Swift’s stable releases of Clang as well as support the Swift project.
https://llvm.org
Other
1.12k stars 330 forks source link

[SR-15128] LLDB Crash #4305

Open swift-ci opened 3 years ago

swift-ci commented 3 years ago
Previous ID SR-15128
Radar rdar://problem/82543261
Original Reporter dalk (JIRA User)
Type Bug
Environment xcode 12.5.0
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler, LLDB for Swift | |Labels | Bug | |Assignee | @adrian-prantl | |Priority | Medium | md5: 1411048b52a88fb0a49aecc05e14bcc1

Issue Description:

100 % reproducible crash when compiling this piece of code. Please note that if MyClass is a struct, it doesnt crash. Same if we change "if let entry = entry" to "if let anything = entry"

class MyClass {

**let** value: Int

**init**(value: Int)

{ self.value = value }

}

func test() {

**let** cachedImages: ThreadSafeMap\<String, MyClass\> = ThreadSafeMap\<String, MyClass\>(label: "")

**let** entry = cachedImages.get(key: "toto")

**guard** **let** entry = entry **else**

{ return }

}

public class ThreadSafeMap\<T: Hashable, U: AnyObject> {

**private** **var** map: \[T: U\] = \[:\]

**private** **let** cacheAccessQueue: DispatchQueue

**public** **init**(label: String)

{ self.cacheAccessQueue = DispatchQueue(label: label, qos: .userInitiated, attributes: .concurrent) }

**public** **func** get(key: T) -\> U? {

    cacheAccessQueue.sync

{ return map[key] }

}

}

typesanitizer commented 3 years ago

@swift-ci create

typesanitizer commented 3 years ago

Could you clarify what exactly is crashing? You said "reproducible crash when compiling this piece of code" – but the title says "LLDB crash". Can you attach a stack trace?

adrian-prantl commented 3 years ago

Yeah, this compiles fine. Can you attach a crash log and/or more instructions?