rust-lang/rust · error · Exception

Cannot bless invalid SBTypeMember object

Error message

Cannot bless invalid SBTypeMember object

What it means

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.

Solutions

  1. Recompile the test crate with full debug info (-C debuginfo=2) and minimal optimization.
  2. Inspect the SBType in LLDB interactively (type lookup) to confirm the field exists and is valid before blessing.
  3. Update or fix the synthetic provider/DWARF so GetFieldAtIndex returns a valid member.

Example fix

# before
rustc -C opt-level=2 test.rs
# after
rustc -C opt-level=0 -C debuginfo=2 test.rs
Defensive patterns

Strategy: type-guard

Validate before calling

def field_from_lldb(field):
    if BLESS and not field.IsValid():
        raise Exception("Cannot bless invalid SBTypeMember object")
    ...

Type guard

def is_valid_field(field: lldb.SBTypeMember) -> bool:
    return field.IsValid()

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10). Data as JSON: /api/errors/1eff736da477cd11. Report an issue: GitHub.

Appendix: source

Thrown at src/etc/lldb_batchmode/from_lldb.py:181


def get_summary_or_value(valobj: lldb.SBValue) -> Optional[str]:
    """`SBValue.GetSummary` only prints summaries from summary providers. It returns `None` if there
    is no summary provider, rather than printing the default representation of the value. Often we
    want any printable representation at all, so this function falls back to `SBValue.GetValue`.
    That covers things like primitives and flat enums that typically don't have summary providers.
    """

    summary = valobj.GetSummary()
    if summary is None:
        return valobj.GetValue()

    return summary


def field_from_lldb(field: lldb.SBTypeMember) -> Field:
    if BLESS and not field.IsValid():
        raise Exception("Cannot bless invalid SBTypeMember object")

    return Field(field.GetName(), field.GetType().GetName(), field.GetOffsetInBytes())


def get_generics(ty: lldb.SBType, sbtarget: lldb.SBTarget) -> list[lldb.SBType]:
    """Platform-agnostic equivalent to `SBType.template_args`. `SBType`'s template functions do not
    work correctly with PDB debug info because PDB has no way to represent template parameters.

    Due to the DWARF spec using
    C++-centric terminology (e.g. `DW_TAG_template_type_parameter`), the following terms are
    interchangable:

    * template type param/arg <-> generic param
    * template value param/arg <-> const generic param

    The difference between "param" and "arg" is largely irrelevant for our purposes.
    Pre-parameterized types (e.g. `Vec<T>`, which could be parameterized to `Vec<u8>`, LLDB calls
    this "template specialization") are not reflected in the DWARF data at all, and are largely an

View on GitHub (pinned to 7088e4b63a)