{"record":{"id":"1142f6852addaf6d","repo":"rust-lang/rust","slug":"cannot-bless-invalid-sbtype-object","errorCode":null,"errorMessage":"Cannot bless invalid SBType object","messagePattern":"Cannot bless invalid SBType object","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/etc/lldb_batchmode/from_lldb.py","lineNumber":225,"sourceCode":"    # template values at the moment.\n    # Eventually we can either change `get_template_args` to skip template values OR update\n    # rustc to output them for DWARF debug info. Also, since it's target-specific behavior, it\n    # shouldn't actually cause tests not to work.\n    if TARGET == Target.WindowsMsvc:\n        return [\n            lldb_lookup.resolve_msvc_template_arg(x, sbtarget)\n            for x in lldb_lookup.get_template_args(name)\n        ]\n    else:\n        return [\n            ty.GetTemplateArgumentType(i)\n            for i in range(ty.GetNumberOfTemplateArguments())\n        ]\n\n\ndef type_from_lldb(ty: lldb.SBType, sbtarget: lldb.SBTarget) -> Type:\n    if BLESS and not ty.IsValid():\n        raise Exception(\"Cannot bless invalid SBType object\")\n\n    generic_types = get_generics(ty, sbtarget)\n    generics = [g.GetName() for g in generic_types]\n\n    return Type(\n        ty.GetByteSize(),\n        ty.GetBasicType(),\n        ty.GetTypeClass(),\n        [field_from_lldb(ty.GetFieldAtIndex(i)) for i in range(ty.GetNumberOfFields())],\n        generics,\n    )\n\n\ndef child_from_lldb(child: lldb.SBValue) -> Child:\n    if BLESS and not child.IsValid():\n        raise Exception(\"Cannot bless invalid child\")\n\n    sbtype: lldb.SBType = child.GetType()","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/etc/lldb_batchmode/from_lldb.py#L207-L243","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before: blindly iterating template args that may be unresolved\nfor i in range(ty.GetNumberOfTemplateArguments()):\n    type_from_lldb(ty.GetTemplateArgumentType(i), target)\n# after: guard each arg\nfor i in range(ty.GetNumberOfTemplateArguments()):\n    arg = ty.GetTemplateArgumentType(i)\n    if arg.IsValid():\n        type_from_lldb(arg, target)\n","handlingStrategy":"type-guard","validationCode":"if BLESS:\n    for i in range(ty.GetNumberOfTemplateArguments()):\n        arg = ty.GetTemplateArgumentType(i)\n        if not arg.IsValid():\n            continue  # or raise a clearer, arg-indexed error\n","typeGuard":"def is_valid_type(ty: lldb.SBType) -> bool:\n    return ty.IsValid()\n","tryCatchPattern":null,"preventionTips":["Guard every SBType from GetTemplateArgumentType with IsValid() before use, especially on PDB/MSVC.","Validate the type interactively in LLDB before running a bless pass."],"tags":["lldb","debuginfo","blessing","rust","generics"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}