Closed
Bug 1179278
Opened 9 years ago
Closed 8 years ago
JS GDB pretty-printers: JSObject printer is flummoxed by bad UTF-8 in class names
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
mozilla48
Tracking | Status | |
---|---|---|
firefox48 | --- | fixed |
People
(Reporter: jimb, Assigned: jimb)
Details
Attachments
(1 file, 3 obsolete files)
3.87 KB,
patch
|
jorendorff
:
review+
|
Details | Diff | Splinter Review |
When printing a JSObject, bogus pointers can lead mozilla.JSObject.JSObjectPtrOrRef.summary to try to print bad data as a class name. This leads to unfortunate output printing stack frames: Python Exception <type 'exceptions.UnicodeDecodeError'> 'utf8' codec can't decode byte 0xc7 in position 0: invalid continuation byte: #30 0x000000000055f666 in js::MapObject::initClass (cx=0x7ffff611b330, obj=) at /home/jimb/moz/dbg/js/src/builtin/MapObject.cpp:1086 I think the solution is to specify an encoding in the call to gdb.Value.string in which all byte strings are valid, like Latin-1, rather than UTF-8.
Comment 1•9 years ago
|
||
Since in practice class names are ASCII, that would make sense.
Assignee | ||
Comment 2•9 years ago
|
||
Assignee | ||
Comment 3•9 years ago
|
||
Doc tweak.
Attachment #8628498 -
Attachment is obsolete: true
Attachment #8628498 -
Flags: review?(ttromey)
Attachment #8628499 -
Flags: review?(ttromey)
Comment 4•9 years ago
|
||
Comment on attachment 8628499 [details] [diff] [review] Handle encoding errors when trying to print JSObject class names. Review of attachment 8628499 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/gdb/mozilla/JSObject.py @@ -30,5 @@ > > def summary(self): > group = deref(self.value['group_']) > classp = group['clasp_'] > - class_name = classp['name'].string() It isn't well-documented, but .string() uses the python codecs and consequently (as you found) errors when decoding invalid data. On the other hand, .lazy_string() uses the gdb codecs and string-printing code, and conversion is done when the value is actually printed. In a case like this it should result in something like <incomplete sequence \c7>. So, I suggest trying that here.
Attachment #8628499 -
Flags: review?(ttromey) → review+
Assignee | ||
Comment 6•8 years ago
|
||
I haven't implemented the changes Tom suggested. Tom, in comment 4, are you saying that simply changing the .string() to .lazy_string() should work?
Flags: needinfo?(jimb) → needinfo?(ttromey)
Assignee | ||
Comment 7•8 years ago
|
||
(In reply to Jim Blandy :jimb from comment #6) > I haven't implemented the changes Tom suggested. > > Tom, in comment 4, are you saying that simply changing the .string() to > .lazy_string() should work? ... that is, calling .lazy_string() *instead* of .string() and the following code? class_name = class_name.string(encoding='latin_1') class_name = class_name.encode(encoding='ascii', errors='backslashreplace') (Why don't you just *try* it, Jim? You have tests...)
Assignee | ||
Comment 8•8 years ago
|
||
(In reply to Tom Tromey :tromey from comment #4) > On the other hand, .lazy_string() uses the gdb codecs and string-printing > code, and conversion is done when the value is actually printed. In a case > like this it should result in something like <incomplete sequence \c7>. I need the class name as a Python string: I compare it to other Python strings, and pass it as an argument to "...".format. The Python 'str' function gives me garbage like <gdb.LazyString object at 0x7f12fc693240>. In the end, I just took matters into my own hands...
Assignee | ||
Comment 9•8 years ago
|
||
Attachment #8628499 -
Attachment is obsolete: true
Attachment #8728198 -
Flags: review?(ttromey)
Assignee | ||
Comment 10•8 years ago
|
||
In the end, what I want is something pretty weird: it's like a string literal, in that it uses source-code things like \xc7, but with no quotes around it.
Assignee | ||
Comment 11•8 years ago
|
||
Actually, I like this version better.
Attachment #8728198 -
Attachment is obsolete: true
Attachment #8728198 -
Flags: review?(ttromey)
Attachment #8728201 -
Flags: review?(ttromey)
Comment 12•8 years ago
|
||
Comment on attachment 8728201 [details] [diff] [review] Handle encoding errors when trying to print JSObject class names. Review of attachment 8728201 [details] [diff] [review]: ----------------------------------------------------------------- Stealing -- it's the least I can do. r=me.
Attachment #8728201 -
Flags: review?(ttromey) → review+
Comment 13•8 years ago
|
||
Ok, sorry, I didn't understand the subtlety here about the quotes. Anyway it seems reasonable enough to me.
Flags: needinfo?(ttromey)
Assignee | ||
Updated•8 years ago
|
OS: Unspecified → Linux
Hardware: Unspecified → All
Target Milestone: --- → mozilla48
Comment 15•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/37e64a9ae974
You need to log in
before you can comment on or make changes to this bug.
Description
•