Skip to content

rust-gdb mishandles very long vectors #29467

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

Closed
huonw opened this issue Oct 30, 2015 · 3 comments
Closed

rust-gdb mishandles very long vectors #29467

huonw opened this issue Oct 30, 2015 · 3 comments
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.)

Comments

@huonw
Copy link
Member

huonw commented Oct 30, 2015

It appears to try to print/handle all elements of a vector, which means it eats a ton of CPU and memory for a very long one. This includes vectors that have been moved from, which have their length field filled in with 0x1d1d...... which is a very large length (it can also occur when trying to debug memory corruption/mistakes: corrupting the length field may make it harder to use the debugger).

fn main() {
    let mut v = Vec::<u32>::new();
    std::mem::forget(v);
}
$ rustc extralong.rs -g
$ rust-gdb ./extralong
...
(gdb) break 4
Breakpoint 1 at 0x48bf: file extralong.rs, line 4.
(gdb) r
Starting program: /home/huon/projects/test-rust/extralong 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, extralong::main () at extralong.rs:4
4   }
(gdb) p v
^CPython Exception <class 'KeyboardInterrupt'> <class 'KeyboardInterrupt'>: 
$1 = Vec<u32>(len: 2097865012304223517, cap: 2097865012304223517)
(gdb) p/x v.len 
$2 = 0x1d1d1d1d1d1d1d1d
(gdb)

(note the ^C to cancel the p v.)

@huonw huonw added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Oct 30, 2015
@michaelwoerister
Copy link
Member

Good catch. That should definitely be handled better.

@draivin
Copy link

draivin commented Dec 4, 2015

As a note, when trying the gdb pretty-printers on windows, whenever I execute info locals on a scope which contains a Vec that has not been declared yet, the uninitialized len is a large number, and the pretty printer will try printing the vector, causing the same error.

@michaelwoerister
Copy link
Member

Fixed by #34639

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.)
Projects
None yet
Development

No branches or pull requests

3 participants