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

made gdb pretty-printing more robust when printing uninitialized vec #66576

Merged
merged 1 commit into from Nov 23, 2019

Conversation

@pnkfelix
Copy link
Member

pnkfelix commented Nov 20, 2019

made gdb pretty-printing more robust when printing uninitialized vec

I based this solution on my reading of:

https://rethinkdb.com/blog/make-debugging-easier-with-custom-pretty-printers#what-is-still-to-be-done

That post claims that there is no clean way to check for garbage pointers, and
so this PR adopts the same solution of tentatively attempting to convert a
dererence to a string, which throws a clean exception on garbage that we can
catch and recover from.

I only made the change to vec and not the other pretty printers because I wanted
to focus my effort on the simplest thing that would resolve issue #64343. In
particular, I considered generalizing this fix to work on the other datatypes
in the pretty-printing support library, but I don't want to invest effort in
that until after we resolve our overall debugging support strategy; see also
issues #60826 and #65564.

Fix #64343

…ed vec.

I based this solution on my reading of:

https://rethinkdb.com/blog/make-debugging-easier-with-custom-pretty-printers#what-is-still-to-be-done

That post claims that there is no clean way to check for garbage pointers, and
so this PR adopts the same solution of tentatively attempting to convert a
dererence to a string, which throws a clean exception on garbage that we can
catch and recover from.

I only made the change to vec and not the other pretty printers because I wanted
to focus my effort on the simplest thing that would resolve issue #64343. In
particular, I *considered* generalizing this fix to work on the other datatypes
in the pretty-printing support library, but I don't want to invest effort in
that until after we resolve our overall debugging support strategy; see also
issues #60826 and #65564.
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Nov 20, 2019

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@pnkfelix

This comment has been minimized.

Copy link
Member Author

pnkfelix commented Nov 20, 2019

Oh, the specific behavior that occurs here is that when it hits garbage data, it terminates the loop over the children and prints inaccessible in place of the element of the last attempted access

I.e. for pretty-uninitialized-vec, you see this:

(gdb) b 'pretty-uninitialized-vec.rs':21
Breakpoint 1 at 0x5884: file ../src/test/debuginfo/pretty-uninitialized-vec.rs, line 21.
(gdb) r
Starting program: /home/pnkfelix/Dev/Mozilla/rust.git/objdir/pretty-uninitialized-vec
warning: Loadable section ".note.gnu.property" outside of ELF segments
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Breakpoint 1, pretty_uninitialized_vec::main () at ../src/test/debuginfo/pretty-uninitialized-vec.rs:21
21          zzz(); // #break
Missing separate debuginfos, use: dnf debuginfo-install libgcc-9.2.1-1.fc30.x86_64
(gdb) print vec
$1 = Vec<i32>(len: 93824992438960, cap: 140737478328320) = {inaccessible}
(gdb) 
@pnkfelix pnkfelix added the T-compiler label Nov 21, 2019
@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Nov 21, 2019

@bors: r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 21, 2019

📌 Commit 9b40e0b has been approved by alexcrichton

pietroalbini added a commit to pietroalbini/rust that referenced this pull request Nov 22, 2019
…r, r=alexcrichton

made gdb pretty-printing more robust when printing uninitialized vec

made gdb pretty-printing more robust when printing uninitialized vec

I based this solution on my reading of:

https://rethinkdb.com/blog/make-debugging-easier-with-custom-pretty-printers#what-is-still-to-be-done

That post claims that there is no clean way to check for garbage pointers, and
so this PR adopts the same solution of tentatively attempting to convert a
dererence to a string, which throws a clean exception on garbage that we can
catch and recover from.

I only made the change to vec and not the other pretty printers because I wanted
to focus my effort on the simplest thing that would resolve issue rust-lang#64343. In
particular, I *considered* generalizing this fix to work on the other datatypes
in the pretty-printing support library, but I don't want to invest effort in
that until after we resolve our overall debugging support strategy; see also
issues rust-lang#60826 and rust-lang#65564.

Fix rust-lang#64343
bors added a commit that referenced this pull request Nov 22, 2019
Rollup of 3 pull requests

Successful merges:

 - #66566 (Document pitfall with `impl PartialEq<B> for A`)
 - #66569 (GitHub Actions: preparations, part 1)
 - #66576 (made gdb pretty-printing more robust when printing uninitialized vec)

Failed merges:

r? @ghost
Centril added a commit to Centril/rust that referenced this pull request Nov 23, 2019
…r, r=alexcrichton

made gdb pretty-printing more robust when printing uninitialized vec

made gdb pretty-printing more robust when printing uninitialized vec

I based this solution on my reading of:

https://rethinkdb.com/blog/make-debugging-easier-with-custom-pretty-printers#what-is-still-to-be-done

That post claims that there is no clean way to check for garbage pointers, and
so this PR adopts the same solution of tentatively attempting to convert a
dererence to a string, which throws a clean exception on garbage that we can
catch and recover from.

I only made the change to vec and not the other pretty printers because I wanted
to focus my effort on the simplest thing that would resolve issue rust-lang#64343. In
particular, I *considered* generalizing this fix to work on the other datatypes
in the pretty-printing support library, but I don't want to invest effort in
that until after we resolve our overall debugging support strategy; see also
issues rust-lang#60826 and rust-lang#65564.

Fix rust-lang#64343
bors added a commit that referenced this pull request Nov 23, 2019
Rollup of 4 pull requests

Successful merges:

 - #65961 (add fn type_name_of_val)
 - #66574 (Update tidy check for error codes testing)
 - #66576 (made gdb pretty-printing more robust when printing uninitialized vec)
 - #66583 (Clarify Step Documentation)

Failed merges:

r? @ghost
@bors bors merged commit 9b40e0b into rust-lang:master Nov 23, 2019
4 checks passed
4 checks passed
pr #20191120.25 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-6.0) Linux x86_64-gnu-llvm-6.0 succeeded
Details
pr (Linux x86_64-gnu-tools) Linux x86_64-gnu-tools succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.