在Rust中调试堆栈溢出是否有任何标准方法?

时间:2016-03-16 16:48:34

标签: rust stack-overflow

获得回溯会很不错。

$ cargo test
    Running target/debug/partition_ops-b31bcf7b82e2e8d5

running 1 test

thread 'create_small' has overflowed its stack
Process didn't exit successfully: `/home/dhardy/other/pippin/target/debug/partition_ops-b31bcf7b82e2e8d5` (signal: 11)

To learn more, run the command again with --verbose.

2 个答案:

答案 0 :(得分:8)

简单的答案是使用GDB:

$ gdb --args target/debug/partition_ops-b31bcf7b82e2e8d5
...
(gdb) run
Starting program: /home/dhardy/other/pippin/target/debug/partition_ops-b31bcf7b82e2e8d5 
Missing separate debuginfos, use: dnf debuginfo-install glibc-2.22-7.fc23.x86_64
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

running 1 test
[New Thread 0x7ffff67ff700 (LWP 30769)]
[New Thread 0x7ffff5fff700 (LWP 30770)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff5fff700 (LWP 30770)]
0x00005555555f8a96 in pippin::detail::elt::PartId::from_num (n=1099511627775) at src/detail/elt.rs:36
36              assert!(n > 0 && n <= Self::max().into_num(), "PartId::from_num(n): n is invalid");
Missing separate debuginfos, use: dnf debuginfo-install libgcc-5.3.1-2.fc23.x86_64
(gdb) bt
#0  0x00005555555f8a96 in pippin::detail::elt::PartId::from_num (n=1099511627775) at src/detail/elt.rs:36
#1  0x00005555555f8b57 in pippin::detail::elt::PartId::max () at src/detail/elt.rs:56
#2  0x00005555555f8ab3 in pippin::detail::elt::PartId::from_num (n=1099511627775) at src/detail/elt.rs:36
#3  0x00005555555f8b57 in pippin::detail::elt::PartId::max () at src/detail/elt.rs:56
...

答案 1 :(得分:0)

使用LLDB:

$ rust-lldb -- target/debug/partition_ops-b31bcf7b82e2e8d5  # append test args here
...
(lldb) run
...
(lldb) bt