Skip to content

Conversation

DerGuteMoritz
Copy link
Collaborator

A CI test run recently failed with this error coming from the resource leak detector:

ERROR in (test-basic-auth-value-encoding) (core.clj:2362)
expected: (= "Basic Og==" (middleware/basic-auth-value nil))
  actual: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.IAtom
 at clojure.core$swap_BANG_.invokeStatic (core.clj:2362)
    clojure.core$swap_BANG_.invoke (core.clj:2362)
    aleph.resource_leak_detector$_reportTracedLeak.invokeStatic (resource_leak_detector.clj:138)
    aleph.resource_leak_detector$_reportTracedLeak.invoke (resource_leak_detector.clj:137)
    aleph.resource_leak_detector.reportTracedLeak (:-1)

However, the test namespace in question isn't even instrumented for leak detection (i.e. there is no aleph.resource-leak-detector/instrument-tests! call at its bottom). Immediately before this error, there is another one, though:

ERROR in (test-shutdown-timeout-1) (resource_leak_detector.clj:103)
Uncaught exception, not in assertion.
expected: nil
  actual: java.lang.RuntimeException: Gave up awaiting leak probe. Try increasing `aleph.resource-leak-detector/max-probe-gc-runs`.

This indicates that there was still a pending leak detection probe which was then (attempted to be) reported in the context of the following test. To prevent such red herrings in the future, we now gracefully report such leaked leaks.

[A CI test
run](https://app.circleci.com/pipelines/github/clj-commons/aleph/769/workflows/1be2f5bc-92a9-4768-aa93-845365476aaf/jobs/753/parallel-runs/0/steps/0-107)
recently failed with this error coming from the resource leak detector:

    ERROR in (test-basic-auth-value-encoding) (core.clj:2362)
    expected: (= "Basic Og==" (middleware/basic-auth-value nil))
      actual: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.IAtom
     at clojure.core$swap_BANG_.invokeStatic (core.clj:2362)
        clojure.core$swap_BANG_.invoke (core.clj:2362)
        aleph.resource_leak_detector$_reportTracedLeak.invokeStatic (resource_leak_detector.clj:138)
        aleph.resource_leak_detector$_reportTracedLeak.invoke (resource_leak_detector.clj:137)
        aleph.resource_leak_detector.reportTracedLeak (:-1)

However, the test namespace in question isn't even instrumented for leak detection (i.e. there is no
`aleph.resource-leak-detector/instrument-tests!` call at its bottom). Immediately before this error,
there is another one, though:

    ERROR in (test-shutdown-timeout-1) (resource_leak_detector.clj:103)
    Uncaught exception, not in assertion.
    expected: nil
      actual: java.lang.RuntimeException: Gave up awaiting leak probe. Try increasing `aleph.resource-leak-detector/max-probe-gc-runs`.

This indicates that there was still a pending leak detection probe which was then (attempted to be)
reported in the context of the following test. To prevent such red herrings in the future, we now
gracefully report such leaked leaks.
@DerGuteMoritz DerGuteMoritz merged commit 962aca5 into master Sep 15, 2025
1 check passed
@DerGuteMoritz DerGuteMoritz deleted the make-leak-detector-robust-against-async-leaks-beyond-test-scope branch September 15, 2025 14:39
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.

1 participant