From dd05514657121c3a4774fb5da6c6ce8e3f428290 Mon Sep 17 00:00:00 2001 From: Ryan Kurtz Date: Tue, 29 Oct 2019 13:28:19 -0400 Subject: [PATCH] GT-3280: Fixing ConcurrentModificationException in python interpreter plugin. --- Ghidra/Features/Base/.launch/Ghidra.launch | 2 +- .../interpreter/InterpreterComponentProvider.java | 11 +++++++---- .../RuntimeScripts/Common/support/launch.properties | 3 +++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Ghidra/Features/Base/.launch/Ghidra.launch b/Ghidra/Features/Base/.launch/Ghidra.launch index a47acf5902..2c45f106e2 100644 --- a/Ghidra/Features/Base/.launch/Ghidra.launch +++ b/Ghidra/Features/Base/.launch/Ghidra.launch @@ -24,5 +24,5 @@ - + diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/InterpreterComponentProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/InterpreterComponentProvider.java index a51652fc3a..7823159b83 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/InterpreterComponentProvider.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/InterpreterComponentProvider.java @@ -171,12 +171,15 @@ public class InterpreterComponentProvider extends ComponentProviderAdapter @Override public void componentActivated() { - // Call the callbacks - firstActivationCallbacks.forEach(l -> l.call()); - // Since we only care about the first activation, clear the list - // of callbacks so future activations don't trigger anything. + // Since we only care about the first activation, clear the list of callbacks so future + // activations don't trigger anything. First save them off to a local list so when we + // process them we aren't affected by concurrent modification due to reentrance. + List callbacks = new ArrayList<>(firstActivationCallbacks); firstActivationCallbacks.clear(); + + // Call the callbacks + callbacks.forEach(l -> l.call()); } @Override diff --git a/Ghidra/RuntimeScripts/Common/support/launch.properties b/Ghidra/RuntimeScripts/Common/support/launch.properties index 483bd1511b..be3256a7b1 100644 --- a/Ghidra/RuntimeScripts/Common/support/launch.properties +++ b/Ghidra/RuntimeScripts/Common/support/launch.properties @@ -46,6 +46,9 @@ VMARGS=-Dcpu.core.override= # Default font size for many java swing elements. VMARGS=-Dfont.size.override= +# Set Jython console encoding (prevents a console error) +VMARGS=-Dpython.console.encoding=UTF-8 + # Eclipse on macOS can have file locking issues if the user home directory is networked. Therefore, # we will disable file locking by default for macOS. Comment the following line out if Eclipse file # locking is needed and known to work.