{"record":{"id":"39164aa31a78cba9","repo":"rust-lang/rust","slug":"cannot-bless-invalid-sbvalue-object","errorCode":null,"errorMessage":"Cannot bless invalid SBValue object","messagePattern":"Cannot bless invalid SBValue object","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/etc/lldb_batchmode/from_lldb.py","lineNumber":259,"sourceCode":"        raise Exception(\"Cannot bless invalid child\")\n\n    sbtype: lldb.SBType = child.GetType()\n\n    if not sbtype.IsPointerType() and sbtype.GetBasicType() != lldb.eBasicTypeInvalid:\n        value = decode_primitive(child)\n    else:\n        value = None\n\n    children = [\n        child_from_lldb(child.GetChildAtIndex(i)) for i in range(child.GetNumChildren())\n    ]\n\n    return Child(child.GetName(), child.GetType().GetName(), value, children)\n\n\ndef variable_from_lldb(var: lldb.SBValue) -> Variable:\n    if BLESS and not var.IsValid():\n        raise Exception(\"Cannot bless invalid SBValue object\")\n\n    sbtype = var.GetType()\n    type_name = sbtype.GetName()\n\n    pretty_type_name = var.GetDisplayTypeName()\n\n    if pretty_type_name == type_name:\n        pretty_type_name = None\n\n    # We never want to store pointer values since they are expected to change from run to run.\n    # For now, we also only want to record values for primitives. In the future, we may support\n    # testing the `get_value` output from syntheticproviders, but the current visualizers do not\n    # implement this so it isn't urgent.\n    if not sbtype.IsPointerType() and sbtype.GetBasicType() != lldb.eBasicTypeInvalid:\n        value = decode_primitive(var)\n    else:\n        value = None\n","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/etc/lldb_batchmode/from_lldb.py#L241-L277","documentation":"Raised by from_lldb.variable_from_lldb during a bless run when the top-level lldb.SBValue for a variable fails IsValid(). This is the entry point for blessing a variable, so an invalid value means there is nothing to record; the guard prevents writing garbage to the golden file.","triggerScenarios":"Calling variable_from_lldb with BLESS=True on an SBValue whose underlying variable was optimized away or whose frame has no such value. Typically reached via bless_variable after frame.FindVariable returned a valid-looking but empty object.","commonSituations":"The variable was optimized out at the breakpoint; the wrong breakpoint index was used; the variable name in the test does not match a real local in the frame.","solutions":["Confirm the variable is live at the breakpoint (recompile with -C opt-level=0 -C debuginfo=2).","Verify the breakpoint index and variable name match what the test expects.","Inspect the frame in LLDB interactively (frame variable) before blessing."],"exampleFix":"# before\nvariable_from_lldb(frame.FindVariable(name))\n# after\nvalobj = frame.FindVariable(name)\nif valobj.IsValid():\n    variable_from_lldb(valobj)\n","handlingStrategy":"type-guard","validationCode":"valobj = frame.FindVariable(var_name)\nif BLESS and not valobj.IsValid():\n    raise Exception(f\"Cannot bless invalid SBValue for variable {var_name}\")\nvariable_from_lldb(valobj)\n","typeGuard":"def is_valid_value(v: lldb.SBValue) -> bool:\n    return v.IsValid()\n","tryCatchPattern":null,"preventionTips":["Check FindVariable().IsValid() immediately before blessing.","Disable optimization so the variable is not elided at the breakpoint."],"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"}