Skip to content

Debug build: native shutdown crashes with DCHECK failed: all_.empty() in browser_context.cc #4

Description

@Thrameos

Summary

In a Debug CMake build, CEF's native shutdown reliably crashes with:

FATAL:cef/libcef/browser/browser_context.cc:44] DCHECK failed: all_.empty().

(SIGTRAP, core dump). DCHECK is compiled out in Release builds, which is presumably why this hasn't been noticed before -- most people build/ship Release. This is a general defect, not specific to any particular test: reproduced with a single JUnit test class and as few as 2 browser create/dispose cycles (ModifiedUtf8Test alone, 100% reproducible across multiple runs).

Reproduction

mkdir jcef_build && cd jcef_build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug ..
ninja jcef
cd ..
tools/run_tests.sh linux64 Debug --config debugPrint=true

Individual test logic completes successfully every time (confirmed via debug prints -- onBeforeClose/cleanupTest/awaitCompletion returned all fire for every test before the crash). The DCHECK fires only in the final process-wide CefApp.dispose()/shutdown teardown, after every test has already finished cleanly.

Impact

Blocks native coverage measurement (gcov/gcovr requires a Debug build for reliable instrumentation) -- see #2. Since the process is killed by the crash before any C++ atexit handler runs, coverage data (.gcda files) is never written, so no native coverage can currently be collected at all, independent of what a Debug build is used for.

Environment

  • CEF 146.0.10+g8219561+chromium-146.0.7680.179, linux64
  • Reproduced under both WSLg's X server and a from-scratch Xvfb+icewm setup

Activity

  1. Thrameos commented on Aug 29, 2026

    @Thrameos
    OwnerAuthor

    Discovered while building out the Coverage job in #2. .azure/scripts/coverage.yml's test-run step is marked continueOnError: true to work around this without hard-blocking the pipeline. See plan/findings.md for full details.

  2. Thrameos commented on Aug 29, 2026

    @Thrameos
    OwnerAuthor

    Mitigated (not fixed) in #2: added a small coverage-only native hook (CoverageTestHelper, only compiled in when ENABLE_COVERAGE is on) that calls __gcov_dump() immediately before the known-crashing CefApp.dispose() call, so CI can still capture real coverage data for everything that ran before the crash (verified: 72 .gcda files now written, gcovr produces a real 27% report). The crash itself still happens every time. Also tried increasing the shutdown message-pump count in Context::Shutdown() (10 -> 200 iterations with a delay) on the theory that it was just not waiting long enough -- did not help, reverted. This issue tracks the actual root cause, still open for a follow-up branch.

  3. added 2 commits that reference this issue on Aug 31, 2026
  4. Thrameos commented on Aug 31, 2026

    @Thrameos
    OwnerAuthor

    Fixed in commit b7baff5 (branch coverage/phase1-value-objects-phase2-handlers).

    Root cause: CefRequestContext_N.getGlobalContextNative() leaked a native
    CefRequestContext reference (and its underlying CefBrowserContext) on
    every browser after the first, whenever CefRequestContext::GetGlobalContext()
    returned a different native wrapper pointer than the one already cached --
    found by pointing a ref/unref/gref trace analyzer at a live capture of the
    crash instead of continuing to test architectural hypotheses.

    Verified 3/3 clean on the minimal repro, and on a real 151-test full-suite run
    (151/169, 18 already-@disabled, 0 failed). Full writeup in plan/findings.md
    and plan/roadmap.md's "MENTAL MODEL" section (this repo's local plan/
    notes, not tracked in this GitHub repo).

    Duplicate of/same root cause as #23, closing both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions