Closed Bug 1739321 Opened 3 years ago Closed 3 years ago

[gdb pretty printers] gdb.error No type named jsstring

Categories

(Core :: JavaScript Engine, defect, P3)

defect

Tracking

()

RESOLVED DUPLICATE of bug 1747269
Tracking Status
firefox-esr91 --- unaffected
firefox94 --- unaffected
firefox95 --- wontfix
firefox96 --- wontfix
firefox97 --- wontfix

People

(Reporter: freddy, Assigned: sfink)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: regression)

Attachments

(5 obsolete files)

When running "./mach mochitest --debugger=gdb <some test>", I experienced this error:
This happened directly when loading the pretty printers, i.e., right after instructing gdb to run the target program.

Traceback (most recent call last):
  File "/home/freddy/gecko/js/src/gdb/mozilla/prettyprinters.py", line 218, in __init__
    self.JSString_ptr_t = gdb.lookup_type("JSString").pointer()
gdb.error: No type named JSString.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/freddy/gecko/obj-x86_64-pc-linux-gnu/build/.gdbinit.py", line 10, in <module>
    mozilla.autoload.register(gdb.current_objfile())
  File "/home/freddy/gecko/js/src/gdb/mozilla/autoload.py", line 40, in register
    mozilla.unwind.register_unwinder(objfile)
  File "/home/freddy/gecko/js/src/gdb/mozilla/unwind.py", line 584, in register_unwinder
    type_cache = UnwinderTypeCache()
  File "/home/freddy/gecko/js/src/gdb/mozilla/unwind.py", line 78, in __init__
    super(UnwinderTypeCache, self).__init__(None)
  File "/home/freddy/gecko/js/src/gdb/mozilla/prettyprinters.py", line 222, in __init__
    raise NotSpiderMonkeyObjfileError
mozilla.prettyprinters.NotSpiderMonkeyObjfileError
Warnung: Missing auto-load script at offset 0 in section .debug_gdb_scripts

This is on our latest git revision 7a917a7e62ff34fc776ddf18b9dd3862a2afda97 (hg rev 0658bfc611aa2025d84fd169cd5d66f2bc445ec9).

This looks like a regression caused by clang13 (bug 1731582), because when I compile with clang12, no error is thrown.

Comparing the gdb info types output for StringType.h, shows that multiple types aren't present when compiling with clang13:

 1155:   JSAtom;
 942:    JSDependentString;
 992:    JSExtensibleString;
 1121:   JSExternalString;
-1083:   JSFatInlineString;
 1012:   JSInlineString;
 788:    JSLinearString;
 709:    JSRope;
 714:    JSRope::UsingBarrier;
-190:    JSString;
-206:    JSString::Data;
 1052:   JSThinInlineString;
-1226:   js::FatInlineAtom;
 1789:   js::IdToPrintableBehavior;
 1287:   js::LittleEndianChars;
-1211:   js::NormalAtom;
 1541:   js::PropertyName;
 1303:   js::StaticStrings;
 1432:   js::StaticStrings::SmallCharTable;
 2076:   js::gc::StringRelocationOverlay;
 1430:   typedef unsigned char js::StaticStrings::SmallChar;
Regressed by: clang-13
Has Regression Range: --- → yes

Set release status flags based on info from the regressing bug 1731582

Blocks: 1736620
Severity: -- → S4
Type: task → defect
Priority: -- → P3

Note that we have a CI job that verifies that the gdb prettyprinters work, and it hasn't been failing. It turns out that it's compiling with gcc.

The clang bugtracker is down right now since they're in the middle of a failing migration to github. But to record some info:

The DWARF info for the .o file that is relevant to JSString contains:

<1><48cbf>: Abbrev Number: 43 (DW_TAG_class_type)
    <48cc0>   DW_AT_calling_convention: 4       (pass by ref)
    <48cc1>   DW_AT_name        : (indirect string, offset: 0x6830): JSLinearString
    <48cc5>   DW_AT_byte_size   : 24
    <48cc6>   DW_AT_decl_file   : 25
    <48cc7>   DW_AT_decl_line   : 788
 <2><48cc9>: Abbrev Number: 5 (DW_TAG_inheritance)
    <48cca>   DW_AT_type        : <0x4862b>
    <48cce>   DW_AT_data_member_location: 0
    <48ccf>   DW_AT_accessibility: 1    (public)
    ...

so a complete declaration of JSLinearString. It is tagged as inheriting from 0x4862b, which is:

 <1><4862b>: Abbrev Number: 19 (DW_TAG_class_type)
    <4862c>   DW_AT_name        : (indirect string, offset: 0x44c1): JSString
    <48630>   DW_AT_declaration : 1
 <2><48630>: Abbrev Number: 20 (DW_TAG_subprogram)
    <48631>   DW_AT_linkage_name: (indirect string, offset: 0x2b059): _ZN8JSString23fillWithRepresentativesEP9JSContextN2JS6HandleIPN2js11ArrayObjectEEE
    <48635>   DW_AT_name        : (indirect string, offset: 0x2b0ac): fillWithRepresentatives
    <48639>   DW_AT_decl_file   : 25
    ...

Now, I don't know how to read DWARF, but the DW_AT_declaration makes it look to me like it's doing only a non-defining (forward? partial?) declaration of the JSString type -- and yet, it's also enumerating fields of it. Which seems a bit weird, but I think the DWARF format version 5 spec says it's ok in section E.2.3.

I have no clue why clang is not emitting the defining declaration of JSString. Hopefully I can remember to file a bug once it's possible again.

Note that this means that a workaround to enable the gdb prettyprinters is to add CC=gcc to your mozconfig.

This is also affecting work being done on Pernosco, which also relies on the debuginfo for these types.

needinfo? glandium just so he's aware.

Flags: needinfo?(mh+mozilla)
Assignee: nobody → sphink
Status: NEW → ASSIGNED
Attachment #9255833 - Attachment description: Bug 1739321 - Avoid pointing to untyped memory with TenuredChunk* pointers → Bug 1739321 - Avoid pointing to untyped memory with TenuredChunk* pointers (reduces UB)

Comment on attachment 9255832 [details]
Bug 1739321 - Avoid UB when allocating JSStrings and BigInts

Revision D134095 was moved to bug 1746699. Setting attachment 9255832 [details] to obsolete.

Attachment #9255832 - Attachment is obsolete: true

Comment on attachment 9255833 [details]
Bug 1739321 - Avoid pointing to untyped memory with TenuredChunk* pointers (reduces UB)

Revision D134096 was moved to bug 1746699. Setting attachment 9255833 [details] to obsolete.

Attachment #9255833 - Attachment is obsolete: true

Comment on attachment 9255859 [details]
Bug 1739321 - Change all callers of js::Allocate<T>() to properly use placement new

Revision D134116 was moved to bug 1746699. Setting attachment 9255859 [details] to obsolete.

Attachment #9255859 - Attachment is obsolete: true
Flags: needinfo?(mh+mozilla)
Pushed by sfink@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3c69c388216d emit debug symbols for all types, not just those that are constructed r=firefox-build-system-reviewers,glandium
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 97 Branch
Status: RESOLVED → REOPENED
Flags: needinfo?(sphink)
Resolution: FIXED → ---
Target Milestone: 97 Branch → ---
Attachment #9255858 - Attachment is obsolete: true

Thanks!

Flags: needinfo?(sphink)
Attachment #9256014 - Attachment is obsolete: true

Fixed by bug 1747269.

Status: REOPENED → RESOLVED
Closed: 3 years ago3 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: