rust-lang/rust · error · Exception
Cannot bless invalid SBType object
Error message
Cannot bless invalid SBType object
What it means
Raised by from_lldb.type_from_lldb during a bless run when an lldb.SBType fails IsValid(). The function needs to read byte size, basic type, type class, fields and generics, none of which are meaningful on an invalid type, so blessing is aborted.
Source
Thrown at src/etc/lldb_batchmode/from_lldb.py:225
# template values at the moment.
# Eventually we can either change `get_template_args` to skip template values OR update
# rustc to output them for DWARF debug info. Also, since it's target-specific behavior, it
# shouldn't actually cause tests not to work.
if TARGET == Target.WindowsMsvc:
return [
lldb_lookup.resolve_msvc_template_arg(x, sbtarget)
for x in lldb_lookup.get_template_args(name)
]
else:
return [
ty.GetTemplateArgumentType(i)
for i in range(ty.GetNumberOfTemplateArguments())
]
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()View on GitHub (pinned to 7088e4b63a)
Solutions
- Verify the SBType is valid in an interactive LLDB session before blessing (script print(ty.IsValid())).
- For PDB targets, ensure get_generics falls back to lldb_lookup.resolve_msvc_template_arg correctly and the template arg name is parseable.
- Recompile with DWARF debug info on non-MSVC targets to sidestep PDB template-arg gaps.
Example fix
# before: blindly iterating template args that may be unresolved
for i in range(ty.GetNumberOfTemplateArguments()):
type_from_lldb(ty.GetTemplateArgumentType(i), target)
# after: guard each arg
for i in range(ty.GetNumberOfTemplateArguments()):
arg = ty.GetTemplateArgumentType(i)
if arg.IsValid():
type_from_lldb(arg, target)
Defensive patterns
Strategy: type-guard
Validate before calling
if BLESS:
for i in range(ty.GetNumberOfTemplateArguments()):
arg = ty.GetTemplateArgumentType(i)
if not arg.IsValid():
continue # or raise a clearer, arg-indexed error
Type guard
def is_valid_type(ty: lldb.SBType) -> bool:
return ty.IsValid()
Prevention
- Guard every SBType from GetTemplateArgumentType with IsValid() before use, especially on PDB/MSVC.
- Validate the type interactively in LLDB before running a bless pass.
When it happens
Trigger: Calling type_from_lldb with BLESS=True on an SBType obtained from e.g. GetTemplateArgumentType(i) that LLDB could not resolve (common with PDB/MSVC where template args are synthesized), or from a dangling SBType after the target's type system changed.
Common situations: MSVC/PDB targets where template argument types are not represented; a generic type's argument fails to resolve; LLDB/clang version regression in type lookup.
Related errors
- Invalid input data path: '{path}'\nIf test data has not been
- Cannot bless invalid SBTypeMember object
- Cannot bless invalid child
- Cannot bless invalid SBValue object
- <bless error: Cannot find variable {var_name}>
AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10).
Data as JSON: /api/errors/1142f6852addaf6d.
Report an issue: GitHub.