Skip to content
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

Add line numbers to windows-gnu backtraces #28004

Merged
merged 3 commits into from
Sep 4, 2015

Conversation

Diggsey
Copy link
Contributor

@Diggsey Diggsey commented Aug 26, 2015

Technically this could also be used for windows-msvc targets, as I believe they have both dwarf and pdb debug information, but I haven't enabled it there as it should really use the native windows APIs for that, instead of libbacktrace.

I wasn't exactly sure where I should put "gnu" specific stuff, so tell me if I should structure things differently.

This is still a WIP, and I haven't tested properly to make sure I haven't broken msvc/linux builds yet.

@rust-highfive
Copy link
Collaborator

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@@ -15,5 +15,5 @@ pub use self::imp::*;
mod imp;

#[cfg(not(any(target_os = "macos", target_os = "ios")))]
#[path = "libbacktrace.rs"]
#[path = "../../../gnu/libbacktrace.rs"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this file instead live inside of src/libstd/sys/common? It can be #[cfg]'d off there and just pub use'd here

@alexcrichton
Copy link
Member

Nice! I've wondered in the past if we should just start using libbacktrace for everything instead of just symbols/filenames/line numbers, it's got a pretty good track record so far.

@Diggsey Diggsey closed this Aug 27, 2015
@Diggsey Diggsey reopened this Aug 27, 2015
@Diggsey
Copy link
Contributor Author

Diggsey commented Aug 27, 2015

Accidentally closed the PR there for a second! Anyway, I've made the changes you suggested - I'm mostly held back by how long it takes to build everything, so I've still been unable to test properly in all configurations.

all(unix, not(any(target_os = "macos", target_os = "ios"))),
all(windows, target_env = "gnu")
)
)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically we don't format this with the newlines here, instead something like:

#[cfg(any(all(unix, not(any(target_os = "macos", target_os = "ios"))),
          all(windows, target_env = "gnu")))]

@alexcrichton
Copy link
Member

Thanks! Just one minor nit and r=me after a squashing of the last 6 commits

@Diggsey
Copy link
Contributor Author

Diggsey commented Aug 27, 2015

All done

@alexcrichton
Copy link
Member

@bors: r+ 4b2910c99ece3dd042f558c7303d372b78395fc0

@alexcrichton
Copy link
Member

Er actually, just remembered, there's a test that tests for line numbers and can you be sure that it's enabled on GNU windows now? I believe the test is src/test/run-pass/backtrace-debuginfo.rs

@bors: r-

@Diggsey
Copy link
Contributor Author

Diggsey commented Aug 27, 2015

I've enabled the tests, and they seem to be passing.

@alexcrichton
Copy link
Member

@bors: r+ 889fee33d47106bd51b06a9927c939fd8c396061

Thanks!

@bors
Copy link
Contributor

bors commented Aug 28, 2015

⌛ Testing commit 889fee3 with merge 4686e32...

@bors
Copy link
Contributor

bors commented Aug 28, 2015

💔 Test failed - auto-mac-64-opt

@aturon
Copy link
Member

aturon commented Aug 28, 2015

@bors: r=alexcrichton

@bors
Copy link
Contributor

bors commented Aug 28, 2015

📌 Commit b6c0d66 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Aug 28, 2015

⌛ Testing commit b6c0d66 with merge bccd8c6...

@bors
Copy link
Contributor

bors commented Aug 28, 2015

💔 Test failed - auto-win-gnu-64-nopt-t

@eddyb
Copy link
Member

eddyb commented Aug 28, 2015

@bors: r=alexcrichton

@alexcrichton
Copy link
Member

@bors: r+ 9173b937807b8cfd749340c5ddbc573c84018a3b

@bors
Copy link
Contributor

bors commented Aug 31, 2015

⌛ Testing commit 9173b93 with merge ab23511...

@bors
Copy link
Contributor

bors commented Sep 1, 2015

💔 Test failed - auto-win-gnu-32-opt

@Diggsey
Copy link
Contributor Author

Diggsey commented Sep 3, 2015

Fixing this is currently blocked by the fact that I'm unable to build rustc to stage2 under i686-pc-windows-gnu, due to the stage1 rustc segfaulting while compiling stage2 libsyntax. It appears to be an llvm bug, and it's proving to be very difficult to reproduce with debug builds of llvm (rustc seems to hang instead of crashing, or it could just be very slow), and Release+Asserts did not help.

The Release backtrace only showed that it might be happening inside llvm's tail-call elimination pass.

@alexcrichton
Copy link
Member

@Diggsey yeah I've seen that happen unfortunately with gcc 5.2.0, although I'm not sure how to downgrade... Last I checked (a few weeks ago I think) it also happened with the HEAD LLVM, and unfortunately I haven't tracked it down much farther than that :(

@Diggsey
Copy link
Contributor Author

Diggsey commented Sep 3, 2015

Ok, I've just disabled the two backtrace tests on 32-bit windows-gnu again, since the problem seems to be unrelated to this PR (#28218).

@bors
Copy link
Contributor

bors commented Sep 4, 2015

☔ The latest upstream changes (presumably #28200) made this pull request unmergeable. Please resolve the merge conflicts.

Diggsey and others added 3 commits September 4, 2015 01:25
This includes the changes from commits:

 - cd8f317
 - fcb30a0
Fix formatting
Remove unused imports
Refactor
Fix msvc build
Fix line lengths
Formatting
Enable backtrace tests
Fix using directive on mac
pwd info
Work-around buildbot PWD bug, and fix libbacktrace configuration
Use alternative to `env -u` which is not supported on bitrig
Disable tests on 32-bit windows gnu
@Diggsey
Copy link
Contributor Author

Diggsey commented Sep 4, 2015

Rebased

@eddyb
Copy link
Member

eddyb commented Sep 4, 2015

@bors r=alexcrichton

@bors
Copy link
Contributor

bors commented Sep 4, 2015

📌 Commit d4fc3ec has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Sep 4, 2015

⌛ Testing commit d4fc3ec with merge 074c4b6...

@bors
Copy link
Contributor

bors commented Sep 4, 2015

💔 Test failed - auto-linux-32-nopt-t

@Diggsey
Copy link
Contributor Author

Diggsey commented Sep 4, 2015

Wat???

@alexcrichton
Copy link
Member

@bors: retry

On Thu, Sep 3, 2015 at 10:47 PM, Diggory Blake [email protected]
wrote:

Wat???


Reply to this email directly or view it on GitHub
#28004 (comment).

bors added a commit that referenced this pull request Sep 4, 2015
Technically this could also be used for `windows-msvc` targets, as I believe they have *both* dwarf and pdb debug information, but I haven't enabled it there as it should really use the native windows APIs for that, instead of libbacktrace.

I wasn't exactly sure where I should put "gnu" specific stuff, so tell me if I should structure things differently.

This is still a WIP, and I haven't tested properly to make sure I haven't broken msvc/linux builds yet.
@bors
Copy link
Contributor

bors commented Sep 4, 2015

⌛ Testing commit d4fc3ec with merge 9d1f820...

@bors bors merged commit d4fc3ec into rust-lang:master Sep 4, 2015
@retep998
Copy link
Member

retep998 commented Sep 4, 2015

🎊

@jonas-schievink
Copy link
Contributor

Hmm... I think this caused the backtrace.rs and backtrace-debuginfo.rs tests to fail for me (on 64-Bit Windows 10, with up-to-date MSYS2):

---- [run-pass] run-pass/backtrace.rs stdout ----

error: test run failed!
status: exit code: 101
command: PATH="x86_64-pc-windows-gnu/stage1/bin/rustlib/x86_64-pc-windows-gnu/lib;C:\Users\Jonas\Documents\rust\build\x86_64-pc-windows-gnu\stage1\bin;C:\msys64\mingw64\bin;C:\msys64\usr\local\bin;C:\msys64\usr\bin;C:\msys64\usr\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\Rust nightly 1.4\bin;C:\Users\Jonas\AppData\Local\GitHub\PortableGit_c2ba306e536fdf878271f7fe636a147ff37326ad\bin;C:\Users\Jonas\AppData\Local\atom\bin;C:\Users\Jonas\bin;C:\msys64\usr\bin\site_perl;C:\msys64\usr\bin\vendor_perl;C:\msys64\usr\bin\core_perl" x86_64-pc-windows-gnu/test/run-pass\backtrace.stage1-x86_64-pc-windows-gnu.exe
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
thread '<main>' panicked at 'bad output: thread '<main>' panicked at 'explicit panic', C:/Users/Jonas/Documents/rust/src/test/run-pass/backtrace.rs:24
stack backtrace:
   0:         0x678fe84e - <unknown>
   1:         0x67907780 - <unknown>
   2:         0x678c56ee - <unknown>
   3:           0x4017b3 - <unknown>
   4:           0x401731 - <unknown>
   5:           0x4028e6 - <unknown>
   6:         0x67908568 - <unknown>
   7:         0x678f07d3 - <unknown>
   8:         0x67908477 - <unknown>
   9:           0x4013ec - <unknown>
  10:           0x40152a - <unknown>
  11:     0x7ffe43c22d91 - <unknown>
', C:/Users/Jonas/Documents/rust/src/test/run-pass/backtrace.rs:55

------------------------------------------

thread '[run-pass] run-pass/backtrace.rs' panicked at 'explicit panic', C:/Users/Jonas/Documents/rust/src/compiletest\runtest.rs:1501


---- [run-pass] run-pass/backtrace-debuginfo.rs stdout ----

error: test run failed!
status: exit code: 101
command: PATH="x86_64-pc-windows-gnu/stage1/bin/rustlib/x86_64-pc-windows-gnu/lib;C:\Users\Jonas\Documents\rust\build\x86_64-pc-windows-gnu\stage1\bin;C:\msys64\mingw64\bin;C:\msys64\usr\local\bin;C:\msys64\usr\bin;C:\msys64\usr\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\Rust nightly 1.4\bin;C:\Users\Jonas\AppData\Local\GitHub\PortableGit_c2ba306e536fdf878271f7fe636a147ff37326ad\bin;C:\Users\Jonas\AppData\Local\atom\bin;C:\Users\Jonas\bin;C:\msys64\usr\bin\site_perl;C:\msys64\usr\bin\vendor_perl;C:\msys64\usr\bin\core_perl" x86_64-pc-windows-gnu/test/run-pass\backtrace-debuginfo.stage1-x86_64-pc-windows-gnu.exe
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
thread '<main>' panicked at 'trace does not match position list: test case 0
thread '<main>' panicked at 'explicit panic', C:/Users/Jonas/Documents/rust/src/test/run-pass/backtrace-debuginfo.rs:84
stack backtrace:
   0:         0x678fe84e - <unknown>
   1:         0x67907780 - <unknown>
   2:         0x678c56ee - <unknown>
   3:           0x401a89 - <unknown>
   4:           0x401979 - <unknown>
   5:           0x401c75 - <unknown>
   6:           0x403e3e - <unknown>
   7:         0x67908568 - <unknown>
   8:         0x678f07d3 - <unknown>
   9:         0x67908477 - <unknown>
  10:           0x4013ec - <unknown>
  11:           0x40152a - <unknown>
  12:     0x7ffe43c22d91 - <unknown>

---
backtrace-debuginfo.rs:125
backtrace-debuginfo.rs:173
', C:/Users/Jonas/Documents/rust/src/test/run-pass/backtrace-debuginfo.rs:139

------------------------------------------

thread '[run-pass] run-pass/backtrace-debuginfo.rs' panicked at 'explicit panic', C:/Users/Jonas/Documents/rust/src/compiletest\runtest.rs:1501

More specifically, ac12c7f works, but d4fc3ec doesn't.

@Diggsey
Copy link
Contributor Author

Diggsey commented Sep 5, 2015

@jonas-schievink Neither of those tests were enabled on windows before this PR, so it's a safe bet that this caused it.

It looks like for some reason libbacktrace is unable to access the dwarf debug info on the executable. Most likely causes are eiither there's no debug info being generated in the first place, or there's some new security restriction on windows 10 that's preventing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants