rust-lang/rust · error · Exception

Cannot bless invalid child

Error message

Cannot bless invalid child

What it means

Raised by from_lldb.child_from_lldb during a bless run when an lldb.SBValue child fails IsValid(). Children are recursively read to build the golden value tree; an invalid child would poison the reference data, so blessing stops.

Source

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

def type_from_lldb(ty: lldb.SBType, sbtarget: lldb.SBTarget) -> Type:
    if BLESS and not ty.IsValid():
        raise Exception("Cannot bless invalid SBType object")

    generic_types = get_generics(ty, sbtarget)
    generics = [g.GetName() for g in generic_types]

    return Type(
        ty.GetByteSize(),
        ty.GetBasicType(),
        ty.GetTypeClass(),
        [field_from_lldb(ty.GetFieldAtIndex(i)) for i in range(ty.GetNumberOfFields())],
        generics,
    )


def child_from_lldb(child: lldb.SBValue) -> Child:
    if BLESS and not child.IsValid():
        raise Exception("Cannot bless invalid child")

    sbtype: lldb.SBType = child.GetType()

    if not sbtype.IsPointerType() and sbtype.GetBasicType() != lldb.eBasicTypeInvalid:
        value = decode_primitive(child)
    else:
        value = None

    children = [
        child_from_lldb(child.GetChildAtIndex(i)) for i in range(child.GetNumChildren())
    ]

    return Child(child.GetName(), child.GetType().GetName(), value, children)


def variable_from_lldb(var: lldb.SBValue) -> Variable:
    if BLESS and not var.IsValid():
        raise Exception("Cannot bless invalid SBValue object")

View on GitHub (pinned to 7088e4b63a)

Solutions

  1. Check the synthetic provider for the type and confirm every indexed child is valid.
  2. Recompile the test crate with -C debuginfo=2 and lower optimization.
  3. Re-bless after fixing the provider so the golden file reflects the corrected child set.

Example fix

# before: recursing blindly
[child_from_lldb(v.GetChildAtIndex(i)) for i in range(v.GetNumChildren())]
# after: skip invalid children during recursion
[child_from_lldb(c) for i in range(v.GetNumChildren()) if (c := v.GetChildAtIndex(i)).IsValid()]
Defensive patterns

Strategy: type-guard

Validate before calling

children = []
for i in range(v.GetNumChildren()):
    c = v.GetChildAtIndex(i)
    if BLESS and not c.IsValid():
        raise Exception(f"Cannot bless invalid child at index {i} of {v.GetName()}")
    children.append(child_from_lldb(c))

Type guard

def is_valid_child(child: lldb.SBValue) -> bool:
    return child.IsValid()

Prevention

When it happens

Trigger: Calling child_from_lldb with BLESS=True on a child from SBValue.GetChildAtIndex(i) that LLDB could not materialize (e.g. a synthesized child that the pretty-printer failed to produce, or a member elided by optimization).

Common situations: A rustc LLDB synthetic provider returns a child count but one of the children is invalid; debug info is incomplete for a nested type; an LLDB upgrade changes the synthetic provider's child layout.

Related errors


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