Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-1 Corrected regrerssion failure

ghidra1b3381bb52635
diff --git a/Ghidra/Framework/DB/src/main/java/db/DBHandle.java b/Ghidra/Framework/DB/src/main/java/db/DBHandle.java
index b75a2a545a..be6eaddc38 100644
--- a/Ghidra/Framework/DB/src/main/java/db/DBHandle.java
+++ b/Ghidra/Framework/DB/src/main/java/db/DBHandle.java
@@ -519,6 +519,7 @@ public class DBHandle {
if (commit) {
masterTable.flush();
if (bufferMgr.checkpoint()) {
+ cachedChangedState = isChanged();
++checkpointNum;
return true;
}
@@ -532,15 +533,13 @@ public class DBHandle {
}
}
finally {
- if (commit) {
- cachedChangedState = isChanged();
- }
txStarted = false;
}
return false;
}
private void cacheChangedState() {
+ // Must be invoked from within a synchronized block when no transaction is active
cachedChangedState = bufferMgr != null && bufferMgr.isChanged();
}
@@ -550,7 +549,10 @@ public class DBHandle {
*
* @return current modification count
*/
- public long getModCount() {
+ public synchronized long getModCount() {
+ if (bufferMgr == null) {
+ return txStartingModCount; // ballpark value (database has been closed)
+ }
return bufferMgr.getModCount();
}
@@ -715,26 +717,6 @@ public class DBHandle {
return tables.size();
}
- /**
- * Revert the current database version to an older version.
- * @param oldVersion
- * @param monitor
- * @return boolean
- * @throws IllegalStateException if the database has modified prior to
- * invoking this method.
- * @throws IllegalArgumentException if this method is invoked more than
- * once or the version file(s) are corrupt.
- */
-// boolean revert(int oldVersion, TaskMonitor monitor) throws IOException {
-// for (int v = (version-1); v >= oldVersion; --v) {
-// monitor.setMessage("Processing Version " + v);
-// bufferMgr.applyVersionFile(db.getVersionFile(v), monitor);
-// if (monitor.isCancelled())
-// return false;
-// }
-// return true;
-// }
-
/**
* Close the database and dispose of the underlying buffer manager.
* Any existing recovery data will be discarded.
@@ -773,8 +755,8 @@ public class DBHandle {
*
* @return true if unsaved changes have been made.
*/
- public boolean isChanged() {
- if (txStarted) {
+ public synchronized boolean isChanged() {
+ if (bufferMgr != null && txStarted) {
return cachedChangedState || txStartingModCount != getModCount();
}
return cachedChangedState;