Skip to content

fix(verifier): reject recursive script handlers#910

Merged
jbachorik merged 3 commits into
developfrom
agent/issue-890-recursion-verifier
Jul 19, 2026
Merged

fix(verifier): reject recursive script handlers#910
jbachorik merged 3 commits into
developfrom
agent/issue-890-recursion-verifier

Conversation

@jbachorik

@jbachorik jbachorik commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #890 by rejecting handler-reachable direct and mutual recursion in BTrace scripts.

  • The source verifier builds a same-script call graph and rejects reachable cycles.
  • The agent verifier records owner-filtered same-class static edges and recognizes singleton self-loops.
  • Persisted probes now preserve and rethrow their verification failure instead of silently accepting failed verification.

Why

Recursive helpers previously passed both verifier layers, allowing a hot probe to consume traced-thread stack and CPU until stack overflow.

Compatibility

Acyclic helpers and trusted scripts retain their existing behavior. This tightens safety only for non-trusted recursive scripts.

Validation

  • :btrace-compiler:test
  • Focused MethodVerifierDslTest and CallGraphTest
  • :btrace-compiler:spotlessCheck :btrace-agent:spotlessCheck
  • git diff --check

This change is Reviewable

jbachorik and others added 3 commits July 18, 2026 11:01
BTraceProbePersisted.checkVerified() now always throws when verification
fails, but the AtomicBoolean-guarded isVerified() let a losing thread fall
through to `return false` before the winning thread populated
verificationFailure, risking an NPE instead of VerifierException. Serialize
verification with a synchronized block so racing callers observe consistent
state.

Also fix the onmethod/ArgsUnsafe golden traces, which called
Throwable.getMessage() directly in a catch block -- a call the verifier has
always disallowed outside BTraceUtils/injected services. This was previously
masked by checkVerified()'s no-op bug and now fails CI now that verification
failures are enforced.
@jbachorik
jbachorik marked this pull request as ready for review July 19, 2026 10:45
@jbachorik
jbachorik merged commit e8f505a into develop Jul 19, 2026
17 checks passed
@jbachorik
jbachorik deleted the agent/issue-890-recursion-verifier branch July 19, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[3.0] Recursion is caught by neither verifier layer — violates bounded-execution guarantee

1 participant