{"record":{"id":"3d73a412f742fcad","repo":"NationalSecurityAgency/ghidra","slug":"bad-exetable-rowid","errorCode":null,"errorMessage":"Bad exetable rowid","messagePattern":"Bad exetable rowid","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/tables/ExeTable.java","lineNumber":317,"sourceCode":"\t\t}\n\t\treturn count;\n\t}\n\n\t/**\n\t * Query for a single executable based on its exetable -id-\n\t * \n\t * @param id the exetable id\n\t * @return the executable row\n\t * @throws SQLException if there is a problem creating or executing the query\n\t */\n\tpublic ExecutableRow querySingleExecutableId(long id) throws SQLException {\n\n\t\tPreparedStatement s =\n\t\t\tselectByIdStatement.prepareIfNeeded(() -> db.prepareStatement(SELECT_BY_ID_STMT));\n\t\ts.setInt(1, (int) id);\n\t\ttry (ResultSet rs = s.executeQuery()) {\n\t\t\tif (!rs.next()) {\n\t\t\t\tthrow new SQLException(\"Bad exetable rowid\");\n\t\t\t}\n\t\t\tExecutableRow row = new ExecutableRow();\n\t\t\textractExecutableRow(rs, row);\n\t\t\treturn row;\n\t\t}\n\t}\n\n\t/**\n\t * Return the executable with matching md5 (if any)\n\t * \n\t * @param md5 the md5 hash to query\n\t * @return the ExecutableRow data or null\n\t * @throws SQLException if there is a problem creating or executing the query\n\t */\n\tpublic ExecutableRow queryMd5ExeMatch(String md5) throws SQLException {\n\n\t\tPreparedStatement s =\n\t\t\tselectByMd5Statement.prepareIfNeeded(() -> db.prepareStatement(SELECT_BY_MD5_STMT));","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/tables/ExeTable.java#L299-L335","documentation":"Thrown by ExeTable.querySingleExecutableId when a SELECT by id returns no rows (rs.next() is false). The requested exetable row id does not exist. This is the read-side analog of error 808: a lookup for an executable that is not present.","triggerScenarios":"Calling querySingleExecutableId(id) with an id not present in exetable. The executable was deleted, the id is foreign, or the database is missing the row. The internal setInt(1, (int) id) cast means a long id outside int range truncates and will not match.","commonSituations":"Looking up an executable by a stale or cross-database id. Querying after a deletion. Int-truncation of large ids. Partial database restore missing exetable rows.","solutions":["Confirm the id was obtained from the same live database.","Use a broader query (e.g., by md5) to locate the executable if the id is uncertain.","Guard long ids against int overflow before calling (id must fit in 32-bit signed range).","Recover or rebuild the database if rows are missing due to corruption."],"exampleFix":"// before\nExecutableRow row = table.querySingleExecutableId(id);\n\n// after\nif (id > Integer.MAX_VALUE || id < Integer.MIN_VALUE) {\n    throw new IllegalArgumentException(\"exe id out of int range: \" + id);\n}\nExecutableRow row = table.querySingleExecutableId(id);","handlingStrategy":"validation","validationCode":"// Guard long ids against int truncation and absence before lookup.\nif (id < Integer.MIN_VALUE || id > Integer.MAX_VALUE) {\n    throw new IllegalArgumentException(\"exe id out of int range: \" + id);\n}\n// Optionally check existence first via a count query.","typeGuard":null,"tryCatchPattern":"try {\n    return exeTable.querySingleExecutableId(id);\n} catch (SQLException e) {\n    if (e.getMessage().contains(\"Bad exetable rowid\")) {\n        return exeTable.queryExecutableMd5(md5); // fallback lookup\n    }\n    throw e;\n}","preventionTips":["Use ids only from the same live database.","Validate id range fits a 32-bit signed int (the internal setInt cast).","Fall back to md5-based lookup when id validity is uncertain."],"tags":["bsim","database","missing-row","lookup","sql-exception"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}