NationalSecurityAgency/ghidra · error · RegisterValueException

Register length is not numeric: ({class}) '{value}'

Error message

Register length is not numeric: ({class}) '{value}'

What it means

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.

Source

Thrown at Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/model/memory/RegisterValueConverter.java:77

			return BigInteger.valueOf(l);
		}
		else if (val instanceof Address a) {
			return a.getOffsetAsBigInteger();
		}
		throw new RegisterValueException(
			"Cannot convert register value: (" + val.getClass() + ") '" + val + "'");
	}

	BigInteger convertRegisterValueToBigInteger() throws RegisterValueException {
		return convertValueToBigInteger(registerValue.getValue());
	}

	int getRegisterValueBitLength() throws RegisterValueException {
		Object objBitLength = registerValue.getParent()
				.getValue(registerValue.getMinSnap(), TraceRegister.KEY_BITLENGTH)
				.getValue();
		if (!(objBitLength instanceof Number numBitLength)) {
			throw new RegisterValueException(
				"Register length is not numeric: (" + objBitLength.getClass() + ") '" +
					objBitLength + "'");
		}
		return numBitLength.intValue();
	}

	public BigInteger getValue() throws RegisterValueException {
		if (value != null) {
			return value;
		}
		return value = convertRegisterValueToBigInteger();
	}

	int getBitLength() throws RegisterValueException {
		if (bitLength != -1) {
			return bitLength;
		}
		return bitLength = getRegisterValueBitLength();

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Ensure the register object has KEY_BITLENGTH set to a Number (e.g. Integer 32) when the register is created.
  2. If the attribute is stored as a String number, write it as an int instead.
  3. Catch RegisterValueException and report which register object lacks a numeric bitlength.

Example fix

// before
regObj.setAttribute(span, TraceRegister.KEY_BITLENGTH, "32"); // String

// after
regObj.setAttribute(span, TraceRegister.KEY_BITLENGTH, 32); // Integer (Number)
Defensive patterns

Strategy: try-catch

Validate before calling

Object bl = regObj.getValue(span, TraceRegister.KEY_BITLENGTH).getValue();
if (!(bl instanceof Number)) {
    regObj.setAttribute(span, TraceRegister.KEY_BITLENGTH, 32); // ensure numeric
}

Type guard

static boolean numericBitLength(Object bl) { return bl instanceof Number; }

Try / catch

try {
    int bits = new RegisterValueConverter(regVal).getRegisterValueBitLength();
} catch (RegisterValueException e) {
    // set KEY_BITLENGTH to a Number on the register object, then retry
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/4936480cb64d05c6. Report an issue: GitHub.