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

All stacktrace lines are "<unknown>" on FreeBSD #78184

Closed
gridbugs opened this issue Oct 21, 2020 · 16 comments · Fixed by #83506
Closed

All stacktrace lines are "<unknown>" on FreeBSD #78184

gridbugs opened this issue Oct 21, 2020 · 16 comments · Fixed by #83506
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows C-bug Category: This is a bug. O-freebsd Operating system: FreeBSD P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@gridbugs
Copy link

gridbugs commented Oct 21, 2020

When panicking, every line of stack traces contain <unknown> instead of a code location. E.g.

$ cat src/main.rs
fn main() {
    panic!("Hello, world!");
}
$ RUST_BACKTRACE=full cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
     Running `target/debug/foo`
thread 'main' panicked at 'Hello, world!', src/main.rs:2:5
stack backtrace:
   0:          0x1044d31 - <unknown>
   1:          0x105c2f0 - <unknown>
   2:          0x1043594 - <unknown>
   3:          0x10467a8 - <unknown>
   4:          0x104646c - <unknown>
   5:          0x1046e35 - <unknown>
   6:          0x1033764 - <unknown>
   7:          0x1032fb8 - <unknown>
   8:          0x1033696 - <unknown>
   9:          0x1032c0c - <unknown>
  10:          0x103237e - <unknown>
  11:          0x1032ff1 - <unknown>
  12:          0x1032cb4 - <unknown>
  13:          0x10471e4 - <unknown>
  14:          0x1032c92 - <unknown>
  15:          0x1032c3b - <unknown>
  16:          0x103210b - <unknown>

I'm on rustc 1.47.0 and FreeBSD 12.1:

$ rustc --version
rustc 1.47.0 (18bf6b4f0 2020-10-07)
$ uname -a
FreeBSD fontaine 12.1-RELEASE-p10 FreeBSD 12.1-RELEASE-p10 GENERIC  amd64

Possible duplicate of #54434

I've tried mounting /proc but it didn't fix the problem.

@jonas-schievink jonas-schievink added A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows C-bug Category: This is a bug. T-libs Relevant to the library team, which will review and decide on the PR/issue. O-freebsd Operating system: FreeBSD labels Oct 21, 2020
@tesuji
Copy link
Contributor

tesuji commented Oct 21, 2020

Can you test on old Rust stable version to see if this is a regression ?

Edit: This is an expected regression rust-lang/backtrace-rs#325.

@gridbugs
Copy link
Author

It worked on 1.46.0:

$ rustup default 1.46.0
info: using existing install for '1.46.0-x86_64-unknown-freebsd'
info: default toolchain set to '1.46.0-x86_64-unknown-freebsd'

  1.46.0-x86_64-unknown-freebsd unchanged - rustc 1.46.0 (04488afe3 2020-08-24)

$ rustc --version
rustc 1.46.0 (04488afe3 2020-08-24)
$ RUST_BACKTRACE=full cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.08s
     Running `target/debug/foo`
thread 'main' panicked at 'Hello, world!', src/main.rs:2:5
stack backtrace:
   0:          0x1036a5d - backtrace::backtrace::libunwind::trace::h55d34efd667ae7f2
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1:          0x1036a5d - backtrace::backtrace::trace_unsynchronized::h22e345d4ced2d4ad
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2:          0x1036a5d - std::sys_common::backtrace::_print_fmt::h19199d69d36cf141
                               at src/libstd/sys_common/backtrace.rs:78
   3:          0x1036a5d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf4a5883ac429a8c0
                               at src/libstd/sys_common/backtrace.rs:59
   4:          0x105325c - core::fmt::write::h034d3b092e0f8bf8
                               at src/libcore/fmt/mod.rs:1076
   5:          0x1035082 - std::io::Write::write_fmt::hcd59a10b4c372132
                               at src/libstd/io/mod.rs:1537
   6:          0x1038808 - std::sys_common::backtrace::_print::h697b7cdcde768e1b
                               at src/libstd/sys_common/backtrace.rs:62
   7:          0x1038808 - std::sys_common::backtrace::print::h2cbe97e71b9f43bf
                               at src/libstd/sys_common/backtrace.rs:49
   8:          0x1038808 - std::panicking::default_hook::{{closure}}::hd560d2eff188e8e5
                               at src/libstd/panicking.rs:198
   9:          0x10384c9 - std::panicking::default_hook::h3225be6477d52e2e
                               at src/libstd/panicking.rs:217
  10:          0x1038e65 - std::panicking::rust_panic_with_hook::h10d7ad778c2ddef3
                               at src/libstd/panicking.rs:526
  11:          0x1030986 - std::panicking::begin_panic::h91786f982b531f94
                               at /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/libstd/panicking.rs:456
  12:          0x10306ec - foo::main::h967e1f2bf0ad1d46
                               at src/main.rs:2
  13:          0x103084e - std::rt::lang_start::{{closure}}::hcd91829aefc439cf
                               at /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/libstd/rt.rs:67
  14:          0x10391ea - std::rt::lang_start_internal::{{closure}}::hc0f35a74710e4a19
                               at src/libstd/rt.rs:52
  15:          0x10391ea - std::panicking::try::do_call::hf3de4c4c1dce977f
                               at src/libstd/panicking.rs:348
  16:          0x10391ea - std::panicking::try::h8b2e697ba94a3253
                               at src/libstd/panicking.rs:325
  17:          0x10391ea - std::panic::catch_unwind::hc4dd4672f0cc4abb
                               at src/libstd/panic.rs:394
  18:          0x10391ea - std::rt::lang_start_internal::ha90c4c8e282f65c1
                               at src/libstd/rt.rs:51
  19:          0x1030832 - std::rt::lang_start::hc1f9ef8afcf5202f
                               at /rustc/04488afe34512aa4c33566eb16d8c912a3ae04f9/src/libstd/rt.rs:67
  20:          0x103071b - main
  21:          0x103010b - _start
                               at /usr/src/lib/csu/amd64/crt1.c:76

@tesuji
Copy link
Contributor

tesuji commented Oct 22, 2020

Do you know if there is a build farm for freebsd like gcc build farm ?
Because we could bisect fo find from which PR caused the regression.

Otherwise, since freebsd is a tier-2 target, not everyone could investigate it.

@rustbot modify labels: T-compiler

@rustbot

This comment has been minimized.

@rustbot rustbot added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Oct 22, 2020
@apiraino
Copy link
Contributor

Assigning P-medium as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.) and removing I-prioritize.

@apiraino apiraino added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Oct 22, 2020
@cutsoy
Copy link
Contributor

cutsoy commented Oct 22, 2020

For what it's worth, this problem occurs on iOS (x86_64-apple-ios) builds too:

1.47.0:

thread '...' panicked at '...', src/lib.rs:9:9
stack backtrace:
   0:        0x10bddaa94 - <unknown>
   1:        0x10be49fd0 - <unknown>
   2:        0x10bdcc41b - <unknown>
   3:        0x10bddf325 - <unknown>
   4:        0x10bddeff2 - <unknown>
   5:        0x10bddf9a3 - <unknown>
   6:        0x10ba57ed4 - <unknown>

  (etc.)

1.46.0:

thread '...' panicked at '...', src/lib.rs:9:9
stack backtrace:
   0:        0x10ce3365e - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hadacd0bee6471e4d
   1:        0x10ce6e60c - core::fmt::write::h80bd4ad93f8618b1
   2:        0x10ce24889 - std::io::Write::write_fmt::hd5b8c68aeda7a2d6
   3:        0x10ce37f45 - std::panicking::default_hook::{{closure}}::h4c78a0dc56f0b2ce
   4:        0x10ce37c1f - std::panicking::default_hook::hbefe2e840ff06337
   5:        0x10ce38583 - std::panicking::rust_panic_with_hook::h40e1a636c83f890f
   6:        0x10ce8d93e - std::panicking::begin_panic::h61bdaef8ee1cf380

   (etc.)

@bjorn3
Copy link
Member

bjorn3 commented Oct 22, 2020

Likely caused by #74682. (switching from libbacktrace to gimli)

It seems that native_libraries is not implemented for FreeBSD: https://github.com/rust-lang/backtrace-rs/blob/8eee2e473e71e659cbd5d32ee78aaf42e8b75752/src/symbolize/gimli.rs#L435-L436 I think this means that it can't find the debuginfo for any libraries and the current executable.

@bjorn3
Copy link
Member

bjorn3 commented Oct 22, 2020

For iOS it may or may not work to extend the condition at https://github.com/rust-lang/backtrace-rs/blob/8eee2e473e71e659cbd5d32ee78aaf42e8b75752/src/symbolize/gimli.rs#L204 to include iOS too.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 22, 2020
@cutsoy
Copy link
Contributor

cutsoy commented Oct 22, 2020

You're right! I submitted a PR to fix it for iOS. Thanks a lot!

@tesuji
Copy link
Contributor

tesuji commented Oct 23, 2020

@cutsoy You might want to file another PR to update backtrace-rs submodule in this repo.

@cutsoy
Copy link
Contributor

cutsoy commented Oct 23, 2020

@lzutao Thanks! #78276

@Aaron1011
Copy link
Member

It looks like dl_iterate_phdr exists on FreeBSD, so I think we could just extend https://github.com/rust-lang/backtrace-rs/blob/8eee2e473e71e659cbd5d32ee78aaf42e8b75752/src/symbolize/gimli.rs#L353-L356 to cover FreeBSD

@tesuji
Copy link
Contributor

tesuji commented Oct 26, 2020

Hi, could you (@cutsoy or @stevebob ) use rustup- toolchain-install-master to install and try this build: 688c68b99d9ece86c9b2389ccaff13c442bcae2e for freebsd?

@gridbugs
Copy link
Author

Looks good!

 $ rustc --version
rustc 1.49.0-nightly (688c68b99 2020-10-26)

$ RUST_BACKTRACE=1 cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/foo`
thread 'main' panicked at 'Hello, world!', src/main.rs:2:5
stack backtrace:
   0: std::panicking::begin_panic
             at /rustc/688c68b99d9ece86c9b2389ccaff13c442bcae2e/library/std/src/panicking.rs:521:12
   1: foo::main
             at ./src/main.rs:2:5
   2: core::ops::function::FnOnce::call_once
             at /rustc/688c68b99d9ece86c9b2389ccaff13c442bcae2e/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

$ RUST_BACKTRACE=full cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/foo`
thread 'main' panicked at 'Hello, world!', src/main.rs:2:5
stack backtrace:
   0:          0x1046341 - std::backtrace_rs::backtrace::libunwind::trace::h38697ba0962b0839
                               at /rustc/688c68b99d9ece86c9b2389ccaff13c442bcae2e/library/std/src/../../backtrace/src/backtrace/libunwind.rs:100:5
   1:          0x1046341 - std::backtrace_rs::backtrace::trace_unsynchronized::h5ef4749c21f60963
                               at /rustc/688c68b99d9ece86c9b2389ccaff13c442bcae2e/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:          0x1046341 - std::sys_common::backtrace::_print_fmt::h49193578845187a0
                               at /rustc/688c68b99d9ece86c9b2389ccaff13c442bcae2e/library/std/src/sys_common/backtrace.rs:67:5
   3:          0x1046341 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb7f4416a63f42308
                               at /rustc/688c68b99d9ece86c9b2389ccaff13c442bcae2e/library/std/src/sys_common/backtrace.rs:46:22
   4:          0x105e2b0 - core::fmt::write::heec8bbbd722d7369
                               at /rustc/688c68b99d9ece86c9b2389ccaff13c442bcae2e/library/core/src/fmt/mod.rs:1076:17
...

@cemeyer
Copy link

cemeyer commented Jan 1, 2021

backtrace-rs issue: rust-lang/backtrace-rs#325

backtrace-rs PR for issue: rust-lang/backtrace-rs#402

@asomers
Copy link
Contributor

asomers commented Mar 25, 2021

What's left to do here? Would a PR that updates the submodule for library/backtrace be sufficient?

bors added a commit to rust-lang-ci/rust that referenced this issue Apr 3, 2021
@bors bors closed this as completed in 5afb167 Apr 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows C-bug Category: This is a bug. O-freebsd Operating system: FreeBSD P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants