{"record":{"id":"1eff736da477cd11","repo":"rust-lang/rust","slug":"cannot-bless-invalid-sbtypemember-object","errorCode":null,"errorMessage":"Cannot bless invalid SBTypeMember object","messagePattern":"Cannot bless invalid SBTypeMember object","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/etc/lldb_batchmode/from_lldb.py","lineNumber":181,"sourceCode":"\n\ndef get_summary_or_value(valobj: lldb.SBValue) -> Optional[str]:\n    \"\"\"`SBValue.GetSummary` only prints summaries from summary providers. It returns `None` if there\n    is no summary provider, rather than printing the default representation of the value. Often we\n    want any printable representation at all, so this function falls back to `SBValue.GetValue`.\n    That covers things like primitives and flat enums that typically don't have summary providers.\n    \"\"\"\n\n    summary = valobj.GetSummary()\n    if summary is None:\n        return valobj.GetValue()\n\n    return summary\n\n\ndef field_from_lldb(field: lldb.SBTypeMember) -> Field:\n    if BLESS and not field.IsValid():\n        raise Exception(\"Cannot bless invalid SBTypeMember object\")\n\n    return Field(field.GetName(), field.GetType().GetName(), field.GetOffsetInBytes())\n\n\ndef get_generics(ty: lldb.SBType, sbtarget: lldb.SBTarget) -> list[lldb.SBType]:\n    \"\"\"Platform-agnostic equivalent to `SBType.template_args`. `SBType`'s template functions do not\n    work correctly with PDB debug info because PDB has no way to represent template parameters.\n\n    Due to the DWARF spec using\n    C++-centric terminology (e.g. `DW_TAG_template_type_parameter`), the following terms are\n    interchangable:\n\n    * template type param/arg <-> generic param\n    * template value param/arg <-> const generic param\n\n    The difference between \"param\" and \"arg\" is largely irrelevant for our purposes.\n    Pre-parameterized types (e.g. `Vec<T>`, which could be parameterized to `Vec<u8>`, LLDB calls\n    this \"template specialization\") are not reflected in the DWARF data at all, and are largely an","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/etc/lldb_batchmode/from_lldb.py#L163-L199","documentation":"Raised by from_lldb.field_from_lldb during a bless run when an lldb.SBTypeMember (a struct/enum field) fails IsValid(). Blessing records reference data, so recording an invalid field would corrupt the golden file; the guard refuses to do so.","triggerScenarios":"Calling field_from_lldb while BLESS is True with an SBTypeMember returned by SBType.GetFieldAtIndex(i) where LLDB could not resolve the field (e.g. incomplete debug info, optimized-out field, PDB/DWARF mismatch).","commonSituations":"Debug info for the type is incomplete because the crate was compiled without -g or with too much optimization; the type is a forward declaration; a clang/LLDB version change makes a previously-resolvable field invalid.","solutions":["Recompile the test crate with full debug info (-C debuginfo=2) and minimal optimization.","Inspect the SBType in LLDB interactively (type lookup) to confirm the field exists and is valid before blessing.","Update or fix the synthetic provider/DWARF so GetFieldAtIndex returns a valid member."],"exampleFix":"# before\nrustc -C opt-level=2 test.rs\n# after\nrustc -C opt-level=0 -C debuginfo=2 test.rs\n","handlingStrategy":"type-guard","validationCode":"def field_from_lldb(field):\n    if BLESS and not field.IsValid():\n        raise Exception(\"Cannot bless invalid SBTypeMember object\")\n    ...\n","typeGuard":"def is_valid_field(field: lldb.SBTypeMember) -> bool:\n    return field.IsValid()\n","tryCatchPattern":null,"preventionTips":["Before blessing, iterate the type's fields in LLDB and confirm each IsValid().","Compile test crates with -C debuginfo=2 -C opt-level=0 so fields are not optimized away."],"tags":["lldb","debuginfo","blessing","rust"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}