Skip to content
Browse files

made gdb pretty-printing script more robust when printing uninitializ…

…ed vec.

I based this solution on my reading of:

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.
  • Loading branch information
pnkfelix committed Nov 20, 2019
1 parent 76ade3e commit 9b40e0bb9af6641a23586fd5999430e4c7622636
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/etc/
@@ -284,10 +284,20 @@ def to_string(self):
("(len: %i, cap: %i)" % (length, cap)))

def children(self):
saw_inaccessible = False
(length, data_ptr, cap) = rustpp.extract_length_ptr_and_cap_from_std_vec(self.__val)
gdb_ptr = data_ptr.get_wrapped_value()
for index in xrange(0, length):
yield (str(index), (gdb_ptr + index).dereference())
if saw_inaccessible:
# rust-lang/rust#64343: passing deref expr to `str` allows
# catching exception on garbage pointer
str((gdb_ptr + index).dereference())
yield (str(index), (gdb_ptr + index).dereference())
except RuntimeError:
saw_inaccessible = True
yield (str(index), "inaccessible")

class RustStdVecDequePrinter(object):

0 comments on commit 9b40e0b

Please sign in to comment.
You can’t perform that action at this time.