From 42395cbd37a19154aa4407bfcf2dfcb1eceedd43 Mon Sep 17 00:00:00 2001 From: Dan <46821332+nsadeveloper789@users.noreply.github.com> Date: Fri, 25 Jun 2021 10:14:54 -0400 Subject: [PATCH] GP-1072: Should grab the readlock before others if any reading is to be done. --- .../java/ghidra/trace/database/DBTrace.java | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/DBTrace.java b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/DBTrace.java index a620aa6575..4912377b78 100644 --- a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/DBTrace.java +++ b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/DBTrace.java @@ -525,22 +525,28 @@ public class DBTrace extends DBCachedDomainObjectAdapter implements Trace, Trace @Override public DBTraceProgramView getFixedProgramView(long snap) { - synchronized (fixedProgramViews) { - DBTraceProgramView view = fixedProgramViews.computeIfAbsent(snap, t -> { - Msg.debug(this, "Creating fixed view at snap=" + snap); - return new DBTraceProgramView(this, snap, baseCompilerSpec); - }); - return view; + // NOTE: The new viewport will need to read from the time manager during init + try (LockHold hold = lockRead()) { + synchronized (fixedProgramViews) { + DBTraceProgramView view = fixedProgramViews.computeIfAbsent(snap, t -> { + Msg.debug(this, "Creating fixed view at snap=" + snap); + return new DBTraceProgramView(this, snap, baseCompilerSpec); + }); + return view; + } } } @Override public DBTraceVariableSnapProgramView createProgramView(long snap) { - synchronized (programViews) { - DBTraceVariableSnapProgramView view = - new DBTraceVariableSnapProgramView(this, snap, baseCompilerSpec); - programViews.put(view, null); - return view; + // NOTE: The new viewport will need to read from the time manager during init + try (LockHold hold = lockRead()) { + synchronized (programViews) { + DBTraceVariableSnapProgramView view = + new DBTraceVariableSnapProgramView(this, snap, baseCompilerSpec); + programViews.put(view, null); + return view; + } } }