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

lldb debuginfo test failure, hash_set/hash_map of size 0 instead of expected size 4? #83891

Closed
pnkfelix opened this issue Apr 5, 2021 · 10 comments · Fixed by #83920
Closed
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug.

Comments

@pnkfelix
Copy link
Member

pnkfelix commented Apr 5, 2021

I tried this code:

time python /media/pnkfelix/Rust/rust.git/x.py build    --stage 1   library/std  && time python /media/pnkfelix/Rust/rust.git/x.py test    --stage 1

I expected to see this happen: successful test suite run

Instead, this happened: debuginfo test failure for pretty-std-collection.rs, saying that an expecting output from the debugger was not found.

error: line not found in debugger output: [...]$2 = size=4 { [0] = { 0 = 1 1 = 10 } [1] = { 0 = 2 1 = 20 } [2] = { 0 = 3 1 = 30 } [3] = { 0 = 4 1 = 40 } }

The specific line it seemed be this one:

// lldb-command:print hash_map
// lldbg-check:[...]$2 = size=4 { [0] = { 0 = 1 1 = 10 } [1] = { 0 = 2 1 = 20 } [2] = { 0 = 3 1 = 30 } [3] = { 0 = 4 1 = 40 } }
// lldbr-check:(std::collections::hash::map::HashMap<u64, u64, [...]>) hash_map = size=4 size=4 { [0] = { 0 = 1 1 = 10 } [1] = { 0 = 2 1 = 20 } [2] = { 0 = 3 1 = 30 } [3] = { 0 = 4 1 = 40 } }

Click to see transcript that includes the full stdout/stderr output as reported by `x.y` + `compiletest`
failures:

---- [debuginfo-lldb] debuginfo/pretty-std-collections.rs stdout ----
NOTE: compiletest thinks it is using LLDB version 1100
NOTE: compiletest thinks it is using LLDB without native rust support

error: line not found in debugger output: [...]$2 = size=4 { [0] = { 0 = 1 1 = 10 } [1] = { 0 = 2 1 = 20 } [2] = { 0 = 3 1 = 30 } [3] = { 0 = 4 1 = 40 } }
status: exit code: 0
command: "/usr/bin/python" "/media/pnkfelix/Rust/rust.git/src/etc/lldb_batchmode.py" "/media/pnkfelix/Rust/rust.git/objdir-opt/build/x86_64-unknown-linux-gnu/test/debuginfo/pretty-std-collections.lldb/a" "/media/\
pnkfelix/Rust/rust.git/objdir-opt/build/x86_64-unknown-linux-gnu/test/debuginfo/pretty-std-collections.lldb/pretty-std-collections.debugger.script"
stdout:
------------------------------------------
LLDB batch-mode script
----------------------
Debugger commands script is '/media/pnkfelix/Rust/rust.git/objdir-opt/build/x86_64-unknown-linux-gnu/test/debuginfo/pretty-std-collections.lldb/pretty-std-collections.debugger.script'.
Target executable is '/media/pnkfelix/Rust/rust.git/objdir-opt/build/x86_64-unknown-linux-gnu/test/debuginfo/pretty-std-collections.lldb/a'.
Current working directory is '/media/pnkfelix/Rust/rust.git/objdir-opt'
Creating a target for '/media/pnkfelix/Rust/rust.git/objdir-opt/build/x86_64-unknown-linux-gnu/test/debuginfo/pretty-std-collections.lldb/a'
settings set auto-confirm true

version
lldb version 11.0.0
command script import /media/pnkfelix/Rust/rust.git/./src/etc/lldb_lookup.py
type synthetic add -l lldb_lookup.synthetic_lookup -x '.*' --category Rust
type summary add -F lldb_lookup.summary_lookup  -e -x -h '^(alloc::([a-z_]+::)+)String$' --category Rust
type summary add -F lldb_lookup.summary_lookup  -e -x -h '^&str$' --category Rust
type summary add -F lldb_lookup.summary_lookup  -e -x -h '^&\[.+\]$' --category Rust
type summary add -F lldb_lookup.summary_lookup  -e -x -h '^(std::ffi::([a-z_]+::)+)OsString$' --category Rust
type summary add -F lldb_lookup.summary_lookup  -e -x -h '^(alloc::([a-z_]+::)+)Vec<.+>$' --category Rust
type summary add -F lldb_lookup.summary_lookup  -e -x -h '^(alloc::([a-z_]+::)+)VecDeque<.+>$' --category Rust
type summary add -F lldb_lookup.summary_lookup  -e -x -h '^(alloc::([a-z_]+::)+)BTreeSet<.+>$' --category Rust
type summary add -F lldb_lookup.summary_lookup  -e -x -h '^(alloc::([a-z_]+::)+)BTreeMap<.+>$' --category Rust
type summary add -F lldb_lookup.summary_lookup  -e -x -h '^(std::collections::([a-z_]+::)+)HashMap<.+>$' --category Rust
type summary add -F lldb_lookup.summary_lookup  -e -x -h '^(std::collections::([a-z_]+::)+)HashSet<.+>$' --category Rust
type summary add -F lldb_lookup.summary_lookup  -e -x -h '^(alloc::([a-z_]+::)+)Rc<.+>$' --category Rust
type summary add -F lldb_lookup.summary_lookup  -e -x -h '^(alloc::([a-z_]+::)+)Arc<.+>$' --category Rust
type summary add -F lldb_lookup.summary_lookup  -e -x -h '^(core::([a-z_]+::)+)Cell<.+>$' --category Rust
type summary add -F lldb_lookup.summary_lookup  -e -x -h '^(core::([a-z_]+::)+)Ref<.+>$' --category Rust
type summary add -F lldb_lookup.summary_lookup  -e -x -h '^(core::([a-z_]+::)+)RefMut<.+>$' --category Rust
type summary add -F lldb_lookup.summary_lookup  -e -x -h '^(core::([a-z_]+::)+)RefCell<.+>$' --category Rust
type category enable Rust

breakpoint set --file 'pretty-std-collections.rs' --line 159
DEBUG: breakpoint added, id = 1
Breakpoint 1: where = a`pretty_std_collections::main::h809023208ec02992 + 1666 at pretty-std-collections.rs:159:5, address = 0x000000000003d6a2
DEBUG: registering breakpoint callback, id = 1
Error while trying to register breakpoint callback, id = 1, message = error: could not get num args: can't find callable: breakpoint_callback

run
Process 775555 stopped * thread #1, name = 'a', stop reason = breakpoint 1.1 frame #0: 0x00005555555916a2 a`pretty_std_collections::main::h809023208ec02992 at pretty-std-collections.rs:159:5 156 hash_set.insert(i\
); 157 } 158 -> 159 zzz(); // #break ^ 160 } 161 162 fn zzz() { Process 775555 launched: '/media/pnkfelix/Rust/rust.git/objdir-opt/build/x86_64-unknown-linux-gnu/test/debuginfo/pretty-std-collections.lldb/a' (x86\
_64)
print vec_deque
(alloc::collections::vec_deque::VecDeque<int>) $0 = size=3 { [0] = 5 [1] = 3 [2] = 7 }
print vec_deque2
(alloc::collections::vec_deque::VecDeque<int>) $1 = size=7 { [0] = 2 [1] = 3 [2] = 4 [3] = 5 [4] = 6 [5] = 7 [6] = 8 }
print hash_map
(std::collections::hash::map::HashMap<unsigned long, unsigned long, core::hash::BuildHasherDefault<pretty_std_collections::SimpleHasher> >) $2 = size=4 { [0] = [1] = [2] = [3] = }
print hash_set
(std::collections::hash::set::HashSet<unsigned long, core::hash::BuildHasherDefault<pretty_std_collections::SimpleHasher> >) $3 = size=4 {}
quit


------------------------------------------
stderr:
------------------------------------------
error: need to add support for DW_TAG_base_type '()' encoded with DW_ATE = 0x7, bit_size = 0

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



failures:
    [debuginfo-lldb] debuginfo/pretty-std-collections.rs

test result: FAILED. 175 passed; 1 failed; 56 ignored; 0 measured; 0 filtered out; finished in 89.52s

Some tests failed in compiletest suite=debuginfo mode=debuginfo host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu


command did not execute successfully: "/media/pnkfelix/Rust/rust.git/objdir-opt/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/media/pnkfelix/Rust/rust.git/objdir-opt/build/x8\
6_64-unknown-linux-gnu/stage1/lib" "--run-lib-path" "/media/pnkfelix/Rust/rust.git/objdir-opt/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/media/pnkfelix/Rust/r\
ust.git/objdir-opt/build/x86_64-unknown-linux-gnu/stage1/bin/rustc" "--src-base" "/media/pnkfelix/Rust/rust.git/src/test/debuginfo" "--build-base" "/media/pnkfelix/Rust/rust.git/objdir-opt/build/x86_64-unknown-li\
nux-gnu/test/debuginfo" "--stage-id" "stage1-x86_64-unknown-linux-gnu" "--suite" "debuginfo" "--mode" "debuginfo" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/med\
ia/pnkfelix/Rust/rust.git/objdir-opt/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck" "--nodejs" "/usr/bin/node" "--npm" "/usr/bin/npm" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -L\
native=/media/pnkfelix/Rust/rust.git/objdir-opt/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/media/pnkfelix/Rust/rust.git/\
objdir-opt/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python" "--lldb-python" "/usr/bin/python" "--gdb" "/usr/bin/gdb" "--lldb-version" "lldb version 11.0.0\n" "--lldb-pyt\
hon-dir" "/usr/lib/lib/python3/dist-packages" "--quiet" "--llvm-version" "12.0.0-rust-dev" "--llvm-components" "aarch64 aarch64asmparser aarch64codegen aarch64desc aarch64disassembler aarch64info aarch64utils agg\
ressiveinstcombine all all-targets analysis arm armasmparser armcodegen armdesc armdisassembler arminfo armutils asmparser asmprinter avr avrasmparser avrcodegen avrdesc avrdisassembler avrinfo binaryformat bitre\
ader bitstreamreader bitwriter cfguard codegen core coroutines coverage debuginfocodeview debuginfodwarf debuginfogsym debuginfomsf debuginfopdb demangle dlltooldriver dwarflinker engine executionengine extension\
s filecheck frontendopenacc frontendopenmp fuzzmutate globalisel hellonew hexagon hexagonasmparser hexagoncodegen hexagondesc hexagondisassembler hexagoninfo instcombine instrumentation interfacestub interpreter \
ipo irreader jitlink libdriver lineeditor linker lto mc mca mcdisassembler mcjit mcparser mips mipsasmparser mipscodegen mipsdesc mipsdisassembler mipsinfo mirparser msp430 msp430asmparser msp430codegen msp430des\
c msp430disassembler msp430info native nativecodegen nvptx nvptxcodegen nvptxdesc nvptxinfo objcarcopts object objectyaml option orcjit orcshared orctargetprocess passes powerpc powerpcasmparser powerpccodegen po\
werpcdesc powerpcdisassembler powerpcinfo profiledata remarks riscv riscvasmparser riscvcodegen riscvdesc riscvdisassembler riscvinfo runtimedyld scalaropts selectiondag sparc sparcasmparser sparccodegen sparcdes\
c sparcdisassembler sparcinfo support symbolize systemz systemzasmparser systemzcodegen systemzdesc systemzdisassembler systemzinfo tablegen target textapi transformutils vectorize webassembly webassemblyasmparse\
r webassemblycodegen webassemblydesc webassemblydisassembler webassemblyinfo windowsmanifest x86 x86asmparser x86codegen x86desc x86disassembler x86info xray" "--cc" "" "--cxx" "" "--cflags" "" "--adb-path" "adb"\
 "--adb-test-dir" "/data/tmp/work" "--android-cross-path" ""
expected success, got: exit code: 1
@pnkfelix pnkfelix added the C-bug Category: This is a bug. label Apr 5, 2021
@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 5, 2021

Incidentally, when I tried to run the test by hand (which admittedly I might have messed up in some way), I saw this:

Click to see some details about my attempt to run `rust-lldb` on a binary.
0-13-18 rust.git/objdir-opt (git:assign_shrink_your_normal_code) % rust-lldb ./pretty-std-collections
(lldb) command script import "/home/pnkfelix/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/etc/lldb_lookup.py"
(lldb) command source -s 0 '/home/pnkfelix/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/etc/lldb_commands'
Executing commands in '/home/pnkfelix/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/etc/lldb_commands'.
(lldb) type synthetic add -l lldb_lookup.synthetic_lookup -x ".*" --category Rust
(lldb) type summary add -F lldb_lookup.summary_lookup  -e -x -h "^(alloc::([a-z_]+::)+)String$" --category Rust
(lldb) type summary add -F lldb_lookup.summary_lookup  -e -x -h "^&str$" --category Rust
(lldb) type summary add -F lldb_lookup.summary_lookup  -e -x -h "^&\\[.+\\]$" --category Rust
(lldb) type summary add -F lldb_lookup.summary_lookup  -e -x -h "^(std::ffi::([a-z_]+::)+)OsString$" --category Rust
(lldb) type summary add -F lldb_lookup.summary_lookup  -e -x -h "^(alloc::([a-z_]+::)+)Vec<.+>$" --category Rust
(lldb) type summary add -F lldb_lookup.summary_lookup  -e -x -h "^(alloc::([a-z_]+::)+)VecDeque<.+>$" --category Rust
(lldb) type summary add -F lldb_lookup.summary_lookup  -e -x -h "^(alloc::([a-z_]+::)+)BTreeSet<.+>$" --category Rust
(lldb) type summary add -F lldb_lookup.summary_lookup  -e -x -h "^(alloc::([a-z_]+::)+)BTreeMap<.+>$" --category Rust
(lldb) type summary add -F lldb_lookup.summary_lookup  -e -x -h "^(std::collections::([a-z_]+::)+)HashMap<.+>$" --category Rust
(lldb) type summary add -F lldb_lookup.summary_lookup  -e -x -h "^(std::collections::([a-z_]+::)+)HashSet<.+>$" --category Rust
(lldb) type summary add -F lldb_lookup.summary_lookup  -e -x -h "^(alloc::([a-z_]+::)+)Rc<.+>$" --category Rust
(lldb) type summary add -F lldb_lookup.summary_lookup  -e -x -h "^(alloc::([a-z_]+::)+)Arc<.+>$" --category Rust
(lldb) type summary add -F lldb_lookup.summary_lookup  -e -x -h "^(core::([a-z_]+::)+)Cell<.+>$" --category Rust
(lldb) type summary add -F lldb_lookup.summary_lookup  -e -x -h "^(core::([a-z_]+::)+)Ref<.+>$" --category Rust
(lldb) type summary add -F lldb_lookup.summary_lookup  -e -x -h "^(core::([a-z_]+::)+)RefMut<.+>$" --category Rust
(lldb) type summary add -F lldb_lookup.summary_lookup  -e -x -h "^(core::([a-z_]+::)+)RefCell<.+>$" --category Rust
(lldb) type category enable Rust
(lldb) target create "./pretty-std-collections"
Current executable set to '/media/pnkfelix/Rust/rust.git/objdir-opt/pretty-std-collections' (x86_64).
(lldb) b pretty-std-collections.rs:159
b pretty-std-collections.rs:159
Breakpoint 1: where = pretty-std-collections`pretty_std_collections::main::h809023208ec02992 + 1666 at pretty-std-collections.rs:159:5, address = 0x0000000000041c82
(lldb) run
run
Process 604949 launched: '/media/pnkfelix/Rust/rust.git/objdir-opt/pretty-std-collections' (x86_64)
Process 604949 stopped
* thread #1, name = 'pretty-std-coll', stop reason = breakpoint 1.1
    frame #0: 0x0000555555595c82 pretty-std-collections`pretty_std_collections::main::h809023208ec02992 at pretty-std-collections.rs:159:5
   156          hash_set.insert(i);
   157      }
   158
-> 159      zzz(); // #break
            ^
   160  }
   161
   162  fn zzz() {
(lldb) print vec_deque
print vec_deque
error: need to add support for DW_TAG_base_type '()' encoded with DW_ATE = 0x7, bit_size = 0
(alloc::collections::vec_deque::VecDeque<int>) $0 = size=3 {
  [0] = 5
  [1] = 3
  [2] = 7
}
(lldb) print vec_deque2
print vec_deque2
(alloc::collections::vec_deque::VecDeque<int>) $1 = size=7 {
  [0] = 2
  [1] = 3
  [2] = 4
  [3] = 5
  [4] = 6
  [5] = 7
  [6] = 8
}
(lldb) print hash_set
print hash_set
(std::collections::hash::set::HashSet<unsigned long, core::hash::BuildHasherDefault<pretty_std_collections::SimpleHasher> >) $2 = size=0
(lldb) print hash_map
print hash_map
(std::collections::hash::map::HashMap<unsigned long, unsigned long, core::hash::BuildHasherDefault<pretty_std_collections::SimpleHasher> >) $3 = size=0
(lldb) q

It seems pretty suspicious that lldb was reporting size=0 for the hash_set and hash_map in these cases, when the unit 8test expects both their sizes to be 4.

(But that also doesn't actually seem to be the behavior that x.py is observing, so that might be user error, or a separate bug entirely.)

@pnkfelix pnkfelix added A-testsuite Area: The testsuite used to check the correctness of rustc A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) labels Apr 5, 2021
@ehuss
Copy link
Contributor

ehuss commented Apr 5, 2021

I'm not sure if you've seen #81813, but the lldb tests only run on macOS on CI. It looks like you are maybe using linux, so this is exercising untested code. In particular, pretty-std-collections is disabled on macOS, so it is not tested anywhere. It's not too surprising that it may have bitrotted.

I'm also curious, are you using lldb installed on your system? Is it the same version of LLVM that rustc was built with?

@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 5, 2021

Yeah I knew the debugger test suite i only enabled in certain contexts, but I couldn't remember the details.

My runs of rust-lldb are using the wrapper from 1.50 stable. Of course that's just a wrapper over what's in my PATH (/usr/bin/lldb in this case), right? lldb version 11.0.0 in this case.

I should probably see if things change if I set llvm-tools=true in my config.toml.

(In any case, I'd say it remains a suboptimal developer experience to have x.py test fail in this manner.)

@ehuss
Copy link
Contributor

ehuss commented Apr 5, 2021

I should probably see if things change if I set llvm-tools=true in my config.toml.

lldb was removed from rustbuild a long while back, so this shouldn't have any impact.

(In any case, I'd say it remains a suboptimal developer experience to have x.py test fail in this manner.)

Agreed, I ran into a similar problem (#81814). As long as the test is disabled in CI, it'll probably keep breaking unfortunately.

I'm pretty certain I tested #81834 locally, and it worked, so somehow it broke again. Maybe @ortem has some insight?

@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 5, 2021

I can bisect, thanks for the link @ehuss !

@artemmukhin
Copy link
Contributor

@ehuss @pnkfelix I checked the latest changes briefly and it looks like #77566 broke HashMap LLDB pretty-printing on Rust 1.51. Note that this line should be used only on the newest versions of HashMap. I'll open a PR to fix this soon.

@ehuss
Copy link
Contributor

ehuss commented Apr 5, 2021

Thanks @ortem, that was quick! And please don't feel obligated to investigate when I ping. It was just a wild guess if you might know what was up.

@artemmukhin
Copy link
Contributor

@ehuss No problem, please feel free to mention me in case of any debugger pretty-printers problems! I'm working on the debugging support in IntelliJ Rust and I'm interested in fixing issues like this ASAP.

@artemmukhin
Copy link
Contributor

artemmukhin commented Apr 5, 2021

By the way, rust-lldb from Rust 1.50 does not include #81834 as far as I understand, so probably this causes the problem.
@ehuss WDYT?

@artemmukhin
Copy link
Contributor

I investigated the problem with a clear mind and found out that LLDB pretty-printer was updated improperly in #77566 (although GDB pretty-printer is OK). Please check the new PR.

@ehuss It would be so great to have LLDB pretty-printers tests on CI. In IntelliJ Rust, we run them on Linux. We use lldb Python package from CLion distribution but I suppose the system package can be linked and used instead (see https://stackoverflow.com/a/31005690/15036963).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug.
Projects
None yet
3 participants