NationalSecurityAgency/ghidra · error · LSHException

Self-score not recorded for

Error message

Self-score not recorded for 

What it means

Thrown by TableScoreCaching.getSelfScore when a BSim database query for a function's self-score (auto-similarity) returns a null result row for the given md5 vector key. The self-score is an optional per-feature-vector value stored in a dedicated optional table; this error means the requested vector exists but its self-score was never computed/committed. It indicates missing analytic metadata rather than a corrupt vector.

Source

Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/TableScoreCaching.java:163

		}
	}

	@Override
	public float getSelfScore(String md5) throws LSHException {
		initialize();
		Float val = cacheMap.get(md5);
		if (val != null) {
			return val.floatValue();
		}
		setUpQuery(1);
		queryValue.keys[0] = md5;
		ResponseOptionalValues response = queryValue.execute(db);
		if (response == null) {
			throw new LSHException(db.getLastError().message);
		}
		val = (Float) response.resultArray[0];
		if (val == null) {
			throw new LSHException("Self-score not recorded for " + md5);
		}
		cacheMap.put(md5, val);
		return val.floatValue();
	}

	@Override
	public void commitSelfScore(String md5, float score) throws LSHException {
		initialize();
		Float val = score;
		cacheMap.put(md5, val);
		setUpInsert(1);
		insertValue.keys[0] = md5;
		insertValue.values[0] = val;
		ResponseOptionalExist response = insertValue.execute(db);
		if (response == null) {
			throw new LSHException(db.getLastError().message);
		}
	}

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Run the BSim self-score generation pass over the database (generate and commitSelfScore for each vector) before issuing queries that require self-scores.
  2. Check that the md5 actually corresponds to a vector present in the database; a vector without a self-score row triggers this.
  3. Verify the optional score table (TABLE_NAME in TableScoreCaching) exists and is populated — if the table is absent or empty, scores were never recorded.
  4. If you control the insertion pipeline, ensure commitSelfScore is called for every vector right after insertion.

Example fix

// before
float score = scoreCaching.getSelfScore(md5); // throws if unscored

// after
if (scoreCaching instanceof TemporaryScoreCaching) {
    // in-memory cache; ensure scores committed first
}
try {
    float score = scoreCaching.getSelfScore(md5);
} catch (LSHException e) {
    // generate and store the self-score, then retry
    float score = generateSelfScore(md5);
    scoreCaching.commitSelfScore(md5, score);
}
Defensive patterns

Strategy: validation

Validate before calling

// Before querying self-scores, ensure the vector was scored.
// For TableScoreCaching there is no public contains(); wrap in try-catch
// and generate the score on miss.
boolean scored = isVectorScored(md5); // app-level tracking
if (!scored) {
    float s = generateSelfScore(md5);
    scoreCaching.commitSelfScore(md5, s);
}

Try / catch

try {
    float score = scoreCaching.getSelfScore(md5);
} catch (LSHException e) {
    if (e.getMessage().startsWith("Self-score not recorded")) {
        float s = generateSelfScore(md5);
        scoreCaching.commitSelfScore(md5, s);
        // retry once
        score = scoreCaching.getSelfScore(md5);
    } else throw e;
}

Prevention

When it happens

Trigger: Calling getSelfScore(md5) on a TableScoreCaching instance (backed by a SQL BSim database) where the md5 has no row in the optional score table. Happens when vectors were inserted without a preceding generate-self-score pass, or when querying self-scores for functions added after the last scoring run. Also if queryValue.execute(db) returns a response whose resultArray[0] is null (row exists but value column is null).

Common situations: Running a BSim similarity query that needs self-scores for normalization before the database has been populated with self-scores. Mixing databases where one was scored and another was not. Importing executables into a BSim database but forgetting to run the self-score generation step. Partial database migrations that copy vectors but not the optional score table.

Related errors


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