Skip to content

Commit c2dcc92

Browse files
adinauerclaude
andcommitted
fix(otel): Avoid deadlock in SentryContextStorage.root() with virtual threads
SentryContextStorage.root() called SentryContextWrapper.wrap() which triggers scope.clone() and acquires locks. Under virtual threads, ReentrantLock.unlock() can re-enter root() via OpenTelemetry executor instrumentation on ForkJoinPool.execute(), causing a deadlock. Return the default OTel root context without wrapping. Scopes are resolved later via attach() or Sentry.getCurrentScopes(). Fixes GH-5226 Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8c1fb22 commit c2dcc92

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sentry-opentelemetry/sentry-opentelemetry-bootstrap/src/main/java/io/sentry/opentelemetry/SentryContextStorage.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public Context current() {
4141

4242
@Override
4343
public Context root() {
44-
return SentryContextWrapper.wrap(ContextStorage.super.root());
44+
// Don't wrap() here — it triggers scope.clone() which acquires locks. Under virtual
45+
// threads, lock.unlock() can re-enter here via OpenTelemetry executor instrumentation, causing
46+
// a deadlock.
47+
return ContextStorage.super.root();
4548
}
4649
}

0 commit comments

Comments
 (0)