-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Port the without_debuginfo test from backtrace-rs to the testsuite
#152860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JayanAXHF
wants to merge
7
commits into
rust-lang:main
Choose a base branch
from
JayanAXHF:tests/porting-no-debuginfo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ed55daa
feat: add a nightly feature for Backtrace Frame access
JayanAXHF e255ee5
test: port `no_debuginfo` to the testsuite
JayanAXHF a7b8152
chore: update `tests/ui/README.md`
JayanAXHF 2ee2332
fixup! chore: update `tests/ui/README.md`
JayanAXHF f245f10
test: add debug info for the test to find the missing symbols
JayanAXHF a2e9dad
fixup chore: revert formatting changes
JayanAXHF a54b642
fix: add exception for aarch64-unknown-linux-gnu
JayanAXHF File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
tests/ui/no_debuginfo/all_frames_have_module_base_address.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| //@ compile-flags: -Cstrip=none -Cdebuginfo=none | ||
| //@ run-pass | ||
| #![feature(backtrace_frames)] | ||
| #![feature(backtrace_internals_accessors)] | ||
| use std::backtrace; | ||
|
|
||
| fn main() { | ||
| let mut missing_base_addresses = 0; | ||
| let btrace = backtrace::Backtrace::force_capture(); | ||
| let frames = btrace.frames(); | ||
| for frame in frames { | ||
| if frame.module_base_address().is_none() { | ||
| missing_base_addresses += 1; | ||
| } | ||
| } | ||
|
|
||
| if cfg!(windows) { | ||
| assert_eq!(missing_base_addresses, 0); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| //@ compile-flags: -Cstrip=none -Cdebuginfo=none | ||
| //@ run-pass | ||
| #![feature(backtrace_frames)] | ||
| #![feature(backtrace_internals_accessors)] | ||
| use std::backtrace; | ||
| fn main() { | ||
| let mut missing_symbols = 0; | ||
| let mut has_symbols = 0; | ||
| let btrace = backtrace::Backtrace::force_capture(); | ||
| let frames = btrace.frames(); | ||
| let mut missing_symbol_indices = Vec::new(); | ||
| for (i, frame) in frames.iter().enumerate() { | ||
| let mut any = false; | ||
| for sym in frame.symbols() { | ||
| if sym.name().is_some() { | ||
| any = true; | ||
| break; | ||
| } | ||
| } | ||
| if any { | ||
| has_symbols += 1; | ||
| } else if !frame.ip().is_null() { | ||
| missing_symbols += 1; | ||
| missing_symbol_indices.push(i); | ||
| } | ||
| } | ||
|
|
||
| // FIXME(#346) currently on MinGW we can't symbolize kernel32.dll and other | ||
| // system libraries, which means we miss the last few symbols. | ||
| if cfg!(windows) && cfg!(target_env = "gnu") { | ||
| assert!(missing_symbols < has_symbols && has_symbols > 4); | ||
| } else if cfg!(all(target_os = "linux", target_env = "gnu")) { | ||
| //NOTE: The reason we allow one missing symbol is because the frame for the | ||
| // `__libc_start_main` fn doesn't have a symbol. See the discussion in | ||
| // #152860 for more details. | ||
| assert!(missing_symbols < has_symbols && missing_symbols <= 1) | ||
| } else { | ||
| for i in missing_symbol_indices { | ||
| eprintln!("missing symbol for frame {i}: {:#?}", frames[i]); | ||
| } | ||
| eprintln!("Full erroneous backtrace: {:#?}", btrace); | ||
| assert_eq!(missing_symbols, 0); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a known problem, so we may need to determine how many frames are missing symbols and it may be aarch64-unknown-linux-gnu specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well it doesn't occur on my arm m2 mac so maybe it's specific? Might wanna check windows too to determine if it's x86
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huuuh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops I misread the target. Do you mind if I rerun the CI for x86 Linux to try to repro the problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@workingjubilee I added some debug info to try to find the frame with the missing info. Also could #152870 be relevant to this?