rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
95.64k stars 12.32k forks source link

`rustc` failed to pass `debuginfo` testsuite when using GDB 15 #122751

Open liushuyu opened 4 months ago

liushuyu commented 4 months ago

Recently, I tried building rustc on my system with a pre-release GDB version (15.0-git, commit: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=1ab9eefe3cea741aba17e11ff28ed48ac3a8293a) and I encountered a lot of debuginfo test failures.

Some examples:

Click to see example failures

``` NOTE: compiletest thinks it is using GDB version 15000050 executing PYTHONPATH="/<>/./src/etc" "/usr/bin/gdb" "-quiet" "-batch" "-nx" "-command=/<>/build/x86_64-unknown-linux-gnu/test/debuginfo/embedded-visualizer.gdb/embedded-visualizer.debugger.script" ------stdout------------------------------ GNU gdb (Ubuntu 15.0.50.20240312-0ubuntu1) 15.0.50.20240312-git Copyright (C) 2024 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word". Breakpoint 1 at 0x1fcd: file tests/debuginfo/embedded-visualizer.rs, line 107. [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Breakpoint 1, embedded_visualizer::main () at tests/debuginfo/embedded-visualizer.rs:107 107 zzz(); // #break Loaded Script Yes gdb_load_rust_pretty_printers.py full name: /<>/src/etc/gdb_load_rust_pretty_printers.py Yes pretty-printer-embedded_visualizer-0 Yes pretty-printer-embedded_visualizer-1 Yes pretty-printer-embedded_visualizer-2 $1 = (0, 0) $2 = (5, 8) $3 = ((0, 0), (5, 8)) $4 = alloc::string::String {vec: alloc::vec::Vec {buf: alloc::raw_vec::RawVec {ptr: core::ptr::unique::Unique {pointer: core::ptr::non_null::NonNull {pointer: 0x55555555aba0}, _marker: core::marker::PhantomData}, cap: 8, alloc: alloc::alloc::Global}, len: 8}} is 10 years old. A debugging session is active. Inferior 1 [process 176000] will be killed. Quit anyway? (y or n) [answered Y; input not from terminal] ------stderr------------------------------ Python Exception : name '__file__' is not defined ------------------------------------------ error: check directive(s) from `/<>/tests/debuginfo/embedded-visualizer.rs` not found in debugger output. errors: (embedded-visualizer.rs:60) `$4 = "Person A" is 10 years old.` the following subset of check directive(s) was found successfully: (embedded-visualizer.rs:51) `Yes pretty-printer-embedded_visualizer-0 ` (embedded-visualizer.rs:52) `Yes pretty-printer-embedded_visualizer-1 ` (embedded-visualizer.rs:54) `$1 = (0, 0)` (embedded-visualizer.rs:56) `$2 = (5, 8)` (embedded-visualizer.rs:58) `$3 = ((0, 0), (5, 8))` status: exit status: 0 command: PYTHONPATH="/<>/./src/etc" "/usr/bin/gdb" "-quiet" "-batch" "-nx" "-command=/<>/build/x86_64-unknown-linux-gnu/test/debuginfo/embedded-visualizer.gdb/embedded-visualizer.debugger.script" --- stdout ------------------------------- GNU gdb (Ubuntu 15.0.50.20240312-0ubuntu1) 15.0.50.20240312-git Copyright (C) 2024 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word". Breakpoint 1 at 0x1fcd: file tests/debuginfo/embedded-visualizer.rs, line 107. [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Breakpoint 1, embedded_visualizer::main () at tests/debuginfo/embedded-visualizer.rs:107 107 zzz(); // #break Loaded Script Yes gdb_load_rust_pretty_printers.py full name: /<>/src/etc/gdb_load_rust_pretty_printers.py Yes pretty-printer-embedded_visualizer-0 Yes pretty-printer-embedded_visualizer-1 Yes pretty-printer-embedded_visualizer-2 $1 = (0, 0) $2 = (5, 8) $3 = ((0, 0), (5, 8)) $4 = alloc::string::String {vec: alloc::vec::Vec {buf: alloc::raw_vec::RawVec {ptr: core::ptr::unique::Unique {pointer: core::ptr::non_null::NonNull {pointer: 0x55555555aba0}, _marker: core::marker::PhantomData}, cap: 8, alloc: alloc::alloc::Global}, len: 8}} is 10 years old. A debugging session is active. Inferior 1 [process 176000] will be killed. Quit anyway? (y or n) [answered Y; input not from terminal] ------------------------------------------ --- stderr ------------------------------- Python Exception : name '__file__' is not defined ------------------------------------------ ---- [debuginfo-gdb] tests/debuginfo/include_string.rs stdout ---- NOTE: compiletest thinks it is using GDB with native rust support executing RUSTC_ICE="0" "/<>/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/<>/tests/debuginfo/include_string.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/<>/debian/cargo" "--sysroot" "/<>/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "-C" "prefer-dynamic" "-o" "/<>/build/x86_64-unknown-linux-gnu/test/debuginfo/include_string.gdb/a" "-A" "internal_features" "-Crpath" "-Lnative=/<>/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Clinker=x86_64-linux-gnu-gcc" "-L" "/<>/build/x86_64-unknown-linux-gnu/test/debuginfo/include_string.gdb/auxiliary" "-g" ------stdout------------------------------ ------stderr------------------------------ ------------------------------------------ NOTE: compiletest thinks it is using GDB version 15000050 executing PYTHONPATH="/<>/./src/etc" "/usr/bin/gdb" "-quiet" "-batch" "-nx" "-command=/<>/build/x86_64-unknown-linux-gnu/test/debuginfo/include_string.gdb/include_string.debugger.script" ------stdout------------------------------ GNU gdb (Ubuntu 15.0.50.20240312-0ubuntu1) 15.0.50.20240312-git Copyright (C) 2024 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word". Breakpoint 1 at 0x12b3: file tests/debuginfo/include_string.rs, line 42. [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Breakpoint 1, include_string::main () at tests/debuginfo/include_string.rs:42 42 zzz(); // #break ------stderr------------------------------ /<>/build/x86_64-unknown-linux-gnu/test/debuginfo/include_string.gdb/include_string.debugger.script:11: Error in sourced command file: Attempt to extract a component of a value that is not a structure. ------------------------------------------ error: gdb failed to execute status: exit status: 1 command: PYTHONPATH="/<>/./src/etc" "/usr/bin/gdb" "-quiet" "-batch" "-nx" "-command=/<>/build/x86_64-unknown-linux-gnu/test/debuginfo/include_string.gdb/include_string.debugger.script" --- stdout ------------------------------- GNU gdb (Ubuntu 15.0.50.20240312-0ubuntu1) 15.0.50.20240312-git Copyright (C) 2024 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word". Breakpoint 1 at 0x12b3: file tests/debuginfo/include_string.rs, line 42. [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Breakpoint 1, include_string::main () at tests/debuginfo/include_string.rs:42 42 zzz(); // #break ------------------------------------------ --- stderr ------------------------------- /<>/build/x86_64-unknown-linux-gnu/test/debuginfo/include_string.gdb/include_string.debugger.script:11: Error in sourced command file: Attempt to extract a component of a value that is not a structure. ------------------------------------------ ```

I am unsure if this is a rustc problem, a GDB pretty printer problem or a GDB problem. This is likely due to a GDB behaviour change, and I tried bisecting the changes for GDB. Then I discovered this commit: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=b0dd661fa16a424f059b1e1d80e779508b1a9a12.

I don't know if this issue should be resolved from rustc, in-repository GDB pretty-printer or GDB itself. Can anyone give me some pointers?

Meta

rustc --version --verbose:

rustc 1.76.0 (07dca489a 2024-02-04)
binary: rustc
commit-hash: 07dca489ac2d933c78d3c5158e3f43beefeb02ce
commit-date: 2024-02-04
host: x86_64-unknown-linux-gnu
release: 1.76.0
LLVM version: 17.0.6

Backtrace

N/A

liushuyu commented 4 months ago

I have requested a Bugzilla account on the GDB upstream and opened a bug report there: https://sourceware.org/bugzilla/show_bug.cgi?id=31517

tromey commented 4 months ago

This is due to the rewrite of unsized type handling in gdb. Details in the gdb bug.