{"record":{"id":"4936480cb64d05c6","repo":"NationalSecurityAgency/ghidra","slug":"register-length-is-not-numeric-class-value","errorCode":null,"errorMessage":"Register length is not numeric: ({class}) '{value}'","messagePattern":"Register length is not numeric: \\((.+?)\\) '(.+?)'","errorType":"exception","errorClass":"RegisterValueException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/model/memory/RegisterValueConverter.java","lineNumber":77,"sourceCode":"\t\t\treturn BigInteger.valueOf(l);\n\t\t}\n\t\telse if (val instanceof Address a) {\n\t\t\treturn a.getOffsetAsBigInteger();\n\t\t}\n\t\tthrow new RegisterValueException(\n\t\t\t\"Cannot convert register value: (\" + val.getClass() + \") '\" + val + \"'\");\n\t}\n\n\tBigInteger convertRegisterValueToBigInteger() throws RegisterValueException {\n\t\treturn convertValueToBigInteger(registerValue.getValue());\n\t}\n\n\tint getRegisterValueBitLength() throws RegisterValueException {\n\t\tObject objBitLength = registerValue.getParent()\n\t\t\t\t.getValue(registerValue.getMinSnap(), TraceRegister.KEY_BITLENGTH)\n\t\t\t\t.getValue();\n\t\tif (!(objBitLength instanceof Number numBitLength)) {\n\t\t\tthrow new RegisterValueException(\n\t\t\t\t\"Register length is not numeric: (\" + objBitLength.getClass() + \") '\" +\n\t\t\t\t\tobjBitLength + \"'\");\n\t\t}\n\t\treturn numBitLength.intValue();\n\t}\n\n\tpublic BigInteger getValue() throws RegisterValueException {\n\t\tif (value != null) {\n\t\t\treturn value;\n\t\t}\n\t\treturn value = convertRegisterValueToBigInteger();\n\t}\n\n\tint getBitLength() throws RegisterValueException {\n\t\tif (bitLength != -1) {\n\t\t\treturn bitLength;\n\t\t}\n\t\treturn bitLength = getRegisterValueBitLength();","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/model/memory/RegisterValueConverter.java#L59-L95","documentation":"Thrown by RegisterValueConverter.getRegisterValueBitLength: the TraceRegister.KEY_BITLENGTH attribute on the register object's parent is expected to be a Number, but the stored value is not numeric (instanceof Number is false). Without a numeric bit length the converter cannot size the register value.","triggerScenarios":"Reading a register value when the register object's 'bitlength' attribute is missing, null, or stored as a String/Object (e.g. \"32\") instead of a numeric type.","commonSituations":"A connector that defines the register object but omits or mis-sets the bitlength attribute; schema/version drift where bitlength changed type; partially-populated trace objects.","solutions":["Ensure the register object has KEY_BITLENGTH set to a Number (e.g. Integer 32) when the register is created.","If the attribute is stored as a String number, write it as an int instead.","Catch RegisterValueException and report which register object lacks a numeric bitlength."],"exampleFix":"// before\nregObj.setAttribute(span, TraceRegister.KEY_BITLENGTH, \"32\"); // String\n\n// after\nregObj.setAttribute(span, TraceRegister.KEY_BITLENGTH, 32); // Integer (Number)","handlingStrategy":"try-catch","validationCode":"Object bl = regObj.getValue(span, TraceRegister.KEY_BITLENGTH).getValue();\nif (!(bl instanceof Number)) {\n    regObj.setAttribute(span, TraceRegister.KEY_BITLENGTH, 32); // ensure numeric\n}","typeGuard":"static boolean numericBitLength(Object bl) { return bl instanceof Number; }","tryCatchPattern":"try {\n    int bits = new RegisterValueConverter(regVal).getRegisterValueBitLength();\n} catch (RegisterValueException e) {\n    // set KEY_BITLENGTH to a Number on the register object, then retry\n}","preventionTips":["Always set KEY_BITLENGTH as a Number when creating a register object.","Validate register-object schema completeness at trace load.","Don't store numeric attributes as String numbers."],"tags":["ghidra","trace-modeling","register-value","schema","numeric"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}