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 332 forks source link

[SR-2136] LLDB asserting on missing glibc module: Ubuntu, master-next, build layout only #4515

Closed a0332500-857b-4d6a-874e-50b63b66b387 closed 8 years ago

a0332500-857b-4d6a-874e-50b63b66b387 commented 8 years ago
Previous ID SR-2136
Radar rdar://problem/27459201
Original Reporter @trfiala
Type Bug
Status Closed
Resolution Done
Environment swift-lldb/master-next branch, Ubuntu 16.04 x86_64, Ubuntu 14.04 x86_64. This happens only with the build layout of lldb/swift. It does not manifest when using the install layout of lldb and swift.
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | LLDB for Swift | |Labels | Bug, Linux | |Assignee | @trfiala | |Priority | Medium | md5: 6e445793b80bac593e7606ca7900ace4

relates to:

Issue Description:

After merging LLVM.org LLDB trunk @r276079 into swift-lldb/master-next, we're getting an assert in many of the LLDB Swift tests here:

swift/lib/ClangImporter/ClangImporter.cpp:402: Assertion !GlibcModuleMapPath.empty() failed

It looks like we're not finding a resource dir to hand over to Swift when we create a clang importer as part of setting up a SwiftASTContext for each module. This might be a temporal issue where we would have found it later.

a0332500-857b-4d6a-874e-50b63b66b387 commented 8 years ago

I'm going to grab this since the most likely candidate for addressing is out this week.

a0332500-857b-4d6a-874e-50b63b66b387 commented 8 years ago

The backtrace for the assert looks like this when running one of the Python-driven LLDB tests against a Swift test subject:

(lldb) thread list
Process 18364 stopped

The issue happens when the test is trying to resolve a breakpoint address by location, and in the process enumerates the swift modules, which creates the SwiftASTContexts, each of which creates a clang module importer, which then gets angry because we haven't told it where to find glibc.

a0332500-857b-4d6a-874e-50b63b66b387 commented 8 years ago

The LLDB test suite uses LLDB and Swift out of the build dir configuration — i.e. not the final install layout. I'm checking with a full package build install layout to see if the behavior is different. This might end up being the same root cause that led to me turning off the in-tree REPL tests on Linux several weeks ago. If they are the same, it would be good to fix that.

a0332500-857b-4d6a-874e-50b63b66b387 commented 8 years ago

> The LLDB test suite uses LLDB and Swift out of the build dir configuration — i.e. not the final install layout. I'm checking with a full package build install layout to see if the behavior is different.

That hunch was correct. The LLDB Swift tests all pass when using the install-layout version of lldb. This seems to imply our resource dir lookup logic is not adequate on Linux when attempting to run lldb out of the build dir to either (1) use the repl or (2) debug a Swift program. Our test suite really depends on running in a build-style layout, so this is going to be important to address.

a0332500-857b-4d6a-874e-50b63b66b387 commented 8 years ago

This issue seems to have the same underlying cause as SR-1300.

a0332500-857b-4d6a-874e-50b63b66b387 commented 8 years ago

The work-around here is to use an install-layout lldb and not try to use it directly out of the build dir.

Meanwhile, I'm going to see if I can get a real solution to this.

a0332500-857b-4d6a-874e-50b63b66b387 commented 8 years ago

I managed to make a fix for this. I'm going to run it through a PR after I do a bit more local testing.

a0332500-857b-4d6a-874e-50b63b66b387 commented 8 years ago

I have a PR testing this fix on swift-lldb/master-next now:
https://github.com/apple/swift-lldb/pull/36

Once I have that tested and submitted successfully, I'll pull this back into swift-lldb/master, and possibly further.

a0332500-857b-4d6a-874e-50b63b66b387 commented 8 years ago

This is working in the swift-lldb/master-next branch, as witnessed in this Ubuntu 15.10 x86_64 build:
https://ci.swift.org/view/swift-master-next/job/oss-lldb-incremental-linux-ubuntu-15_10-master-next/30/

It was developed on Ubuntu 16.04 x86_64, so works there as well. I'm waiting on the Ubuntu 14.04 x86_64 builder to work through it. Once those are clear, I'll get this in swift-lldb/master.

a0332500-857b-4d6a-874e-50b63b66b387 commented 8 years ago

This was fixed a while back.