swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.6k stars 10.37k forks source link

[SR-15478] Incorrect dwarf debug info #57783

Open glbrntt opened 3 years ago

glbrntt commented 3 years ago
Previous ID SR-15478
Radar rdar://problem/85343060
Original Reporter @glbrntt
Type Bug

Attachment: Download

Environment `root@e4cea293ccd7:/code# swift --version` `Swift version 5.5.1 (swift-5.5.1-RELEASE)` `Target: x86_64-unknown-linux-gnu` `root@e4cea293ccd7:/code# cat /etc/os-release` `NAME="Ubuntu"` `VERSION="18.04.6 LTS (Bionic Beaver)"` `ID=ubuntu` `ID_LIKE=debian` `PRETTY_NAME="Ubuntu 18.04.6 LTS"` `VERSION_ID="18.04"`
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | | |Labels | Bug | |Assignee | @adrian-prantl | |Priority | Medium | md5: e2248e729d1d5f8224cc2d485f8bfd9c

Issue Description:

When running a program which hits a precondition failure at a certain point in the program, the backtrace produced (by swift-backtrace) is missing most of the frames. I've narrowed this down to the presence of a didSet block which is hit just before the precondition failure (the backtrace is complete if the didSet block is commented out, see attachments).

Additionally, when running the repro without the deliberate precondition failure and with the scudo sanitizer enabled we hit a segfault in libbacktrace.

As a result of this we think that the dwarf info is somehow incorrect.

To reproduce

The attached archive contains the source for the repro.

To run the repro you need to run two instances of the Echo product, a client and a server. The client will hit the precondition failure.

swift build -c release --product Echo

To run the server:

./.build/release/Echo server

To run the client – which should crash and emit a backtrace:

./.build/release/Echo client "hello"

The source tree, as attached, will produce the partial stack trace. To produce the complete stack trace comment out the didSet block in 'Sources/GRPC/GRPCClientStateMachine.swift' L136-L147.

glbrntt commented 3 years ago

@swift-ci create

adrian-prantl commented 3 years ago

I am not familiar with swift-backtrace — can it read inline frame info? If you run the crashing program in LLDB does it show a more complete backtrace?

glbrntt commented 3 years ago

Yes it can. I'm not sure if swift-backtrace is relevant here, it's just how we first observed the issue. LLDB also does not show a complete backtrace.