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.11k stars 327 forks source link

[SR-10527] swift-lldb crashes setting breakpoint on app with deployment target <12.0 #4571

Open swift-ci opened 5 years ago

swift-ci commented 5 years ago
Previous ID SR-10527
Radar None
Original Reporter ivhernandez (JIRA User)
Type Bug
Environment Xcode 10.2.1 lldb version 7.0.0 Swift version 5.0-dev (LLVM 06f1615069, Swift d5426bc58a)
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | LLDB for Swift | |Labels | Bug, LLDBCrash | |Assignee | None | |Priority | Medium | md5: 0195b20bfcafd1f5f212126750e70ab6

Issue Description:

Repro Steps:

  1. Create a new single view application Xcode project.

  2. Set deployment target to 11.4 or anything below 12.0.

  3. Build application.

  4. Boot, install, launch on a simulator with simctl.

  5. Attach to process by pid with swift-lldb.

  6. Run command: `b ViewController.swift:14`

The crash is occuring in GenType.cpp in swift::irgen::TypeConverter::TypeConverter() with error:
_LLVM ERROR: Cannot read '/Users/ivanhernandez/Desktop/GitHub_Clones/swift-lldb/build/Debug/LLDB.framework/Resources/Swift/iphonesimulator/layouts-x86_64.yaml'
Assertion failed: (e == 0), function \~recursivemutex, file /BuildRoot/Library/Caches/com.apple.xbs/Sources/libcxx/libcxx-400.9.4/src/mutex.cpp, line 64.\

This occurs when using a deployment target under 12.0. Looks like the crash is avoided in iOS >= 12.0 because the TypeConverter constructor returns early if SupportsObjCMetadataUpdateCallback(Triple) is true which happens when iOS version is >=12.2 or macOS version >= 10.14.4. When using deployment target 12.0 or greater, the triple is set to "x86_64--macosx12.2.0" for some reason and 12.2.0 >= 10.14.4 so the constructor exits early. On iOS 11.4 and lower, the triple is "x86_64-apple-ios11.4.0". The constructor does not returns early and instead tries to read LLDB.framework/Resources/Swift/iphonesimulator/layouts-x86_64.yaml which doesn't exist and swift-lldb crashes.

I am using swift-lldb built from the 'stable' branch at commit d5426bc58a8feea9f56436976807cec1ddd0b67e and swift from the 'master' branch. This crash does not occur when using swift-lldb and swift from the 'swift-5.0-branch' branch.

*Stack trace: *
(lldb) bt

belkadan commented 5 years ago

cc @slavapestov, @dcci