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 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 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.
@rust-highfive
Copy link
Collaborator

r? @alexcrichton

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 20, 2019
@pnkfelix
Copy link
Member Author

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 Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 21, 2019
@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Nov 21, 2019

📌 Commit 9b40e0b has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 21, 2019
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

debuginfo/pretty-uninitialized-vec fails with Cannot access memory at address 0x7fffff7fe000
4 participants