{"record":{"id":"70792eada24c90ca","repo":"NationalSecurityAgency/ghidra","slug":"error-70792e","errorCode":null,"errorMessage":"{}","messagePattern":"\\{\\}","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/file/VectorStore.java","lineNumber":74,"sourceCode":"\t\tif (vectors == null) {\n\t\t\treturn EmptyIterator.INSTANCE;\n\t\t}\n\t\treturn vectors.values().iterator();\n\t}\n\n\tpublic synchronized VectorStoreEntry getVectorById(long id) {\n\t\tinit();\n\t\tif (vectors == null) {\n\t\t\treturn null;\n\t\t}\n\t\treturn vectors.get(id);\n\t}\n\n\tprivate void loadVectors() throws SQLException {\n\t\t// NOTE: assume file DB (see constructor above)\n\t\ttry (H2FileFunctionDatabase fnDb = new H2FileFunctionDatabase(serverInfo)) {\n\t\t\tif (!fnDb.initialize()) {\n\t\t\t\tthrow new SQLException(fnDb.getLastError().message);\n\t\t\t}\n\t\t\tvectors = fnDb.readVectorMap();\n\t\t}\n\t}\n\n\tpublic synchronized void invalidate() {\n\t\tvectors = null;\n\t}\n\n\tpublic synchronized void update(VectorStoreEntry entry) {\n\t\tif (vectors != null) {\n\t\t\tvectors.put(entry.id(), entry);\n\t\t}\n\t}\n\n\tpublic synchronized void update(long id, int count) {\n\t\tif (vectors == null) {\n\t\t\treturn;","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/file/VectorStore.java#L56-L92","documentation":"Thrown by VectorStore.loadVectors() when H2FileFunctionDatabase.initialize() returns false. The exception message is the raw error from getLastError().message, which can be any database initialization failure: file not found, schema version mismatch, permission denied, or H2 engine error.","triggerScenarios":"The H2 database file referenced by the BSim serverInfo does not exist, is not readable, has an incompatible schema version, or is locked by another process. Called lazily from VectorStore.init() which is triggered by the first getVectorById(), update(), or similar access.","commonSituations":"Pointing BSim at a database file path that doesn't exist or has wrong permissions; upgrading Ghidra without migrating the BSim database schema; the H2 file is still locked by a previous JVM process that crashed.","solutions":["Verify the database file path in serverInfo exists and is readable by the current process.","Check for a stale lock file (*.lock.db) left by a crashed JVM and remove it if no process is using the database.","Ensure the database was created or last migrated with a compatible Ghidra version; run any required schema migration.","If initializing a fresh database, ensure H2FileFunctionDatabase.initialize() prerequisites (correct serverInfo, valid temp directory) are met."],"exampleFix":"// before: VectorStore silently fails to load, throwing a vague error\ntry {\n    VectorStore store = new VectorStore(serverInfo);\n    store.getVectorById(42); // triggers lazy load, may throw\n} catch (SQLException e) {\n    // message is opaque: just the DB's last error text\n}\n\n// after: validate the DB file exists and is accessible before loading\nPath dbPath = Paths.get(serverInfo.getDatabaseFilePath());\nif (!Files.exists(dbPath)) {\n    throw new IOException(\"BSim database file not found: \" + dbPath);\n}\nVectorStore store = new VectorStore(serverInfo);\nstore.getVectorById(42);","handlingStrategy":"validation","validationCode":"Path dbFile = Paths.get(serverInfo.getDatabaseFilePath());\nif (!Files.exists(dbFile)) {\n    throw new FileNotFoundException(\"BSim database file not found: \" + dbFile);\n}\nif (!Files.isReadable(dbFile)) {\n    throw new IOException(\"BSim database file is not readable: \" + dbFile);\n}\n// Check for stale lock\nPath lockFile = dbFile.resolveSibling(dbFile.getFileName() + \".lock.db\");\nif (Files.exists(lockFile) && !isJvmAlive(lockFile)) {\n    Files.delete(lockFile);\n}\nVectorStore store = new VectorStore(serverInfo);","typeGuard":null,"tryCatchPattern":"try {\n    store.getVectorById(id);\n} catch (SQLException e) {\n    // e.getMessage() is the raw error from H2FileFunctionDatabase.initialize()\n    // Log the underlying cause for diagnostics\n    log.error(\"Failed to load BSim vectors from {}\", serverInfo, e);\n    throw new BSimInitializationException(\"Cannot open BSim database: \" + e.getMessage(), e);\n}","preventionTips":["Verify the database file exists and is readable before creating a VectorStore.","Remove stale .lock.db files from crashed JVM processes before opening.","Ensure the Ghidra version matches the one that created the BSim database to avoid schema mismatch."],"tags":["bsim","ghidra","database","h2","initialization","file-io"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}