Skip to content

Commit

Permalink
[GR-38002] Dispose the agent initialization binding on close.
Browse files Browse the repository at this point in the history
PullRequest: graal/11524
  • Loading branch information
entlicher committed Apr 8, 2022
2 parents ec27cac + 1c791c0 commit 5d35927
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class InsightPerSource implements ContextsListener, AutoCloseable, LoadSou
private final Supplier<Source> src;
private final AgentObject insight;
private final IgnoreSources ignoredSources;
private EventBinding<?> agentBinding;
private volatile EventBinding<?> agentBinding;
/* @GuardedBy("this") */
private InsightInstrument.Key sourceBinding;
/* @GuardedBy("this") */
Expand Down Expand Up @@ -160,6 +160,11 @@ public void close() {
bindings = null;
}
onInit.dispose();
EventBinding<?> agentInitBinding = agentBinding;
if (agentInitBinding != null) {
agentInitBinding.dispose();
}
agentBinding = null;
instrument.closeKeys(keys);
}

Expand Down Expand Up @@ -264,8 +269,11 @@ final class InitializeLater implements ExecutionEventListener {

@Override
public void onEnter(EventContext ctx, VirtualFrame frame) {
CompilerDirectives.transferToInterpreter();
agentBinding.dispose();
CompilerDirectives.transferToInterpreterAndInvalidate();
EventBinding<?> agentInitBinding = agentBinding;
if (agentInitBinding != null) {
agentInitBinding.dispose();
}
initializeAgent(context);
}

Expand Down

0 comments on commit 5d35927

Please sign in to comment.