Skip to content

[BUG] Intermittent SIGBUS (exit 135) in MTP test hosts on Linux with dynamic instrumentation (dotnet-coverage 18.11.2) #253

Open

Description

@zidad
  • Linux: MTP test hosts intermittently die at startup with SIGBUS (exit 135) under dotnet-coverage collect with default dynamic instrumentation; dotnet test reports Zero tests ran, module varies
  • Static instrumentation (EnableDynamicManagedInstrumentation=false, EnableStaticManagedInstrumentation=true, --include-files) or no coverage: no crashes
  • Env: GitHub Actions ubuntu-24.04 (8 vCPU), .NET 10.0.12 (also seen on 10.0.11), dotnet-coverage 18.11.2, TUnit 1.70.1 / MTP 2.4.1, --report-trx
  • Repro: 8 MTP test apps started in parallel under one dotnet-coverage collect session, 40 iterations (320 host starts) per mode
Mode Exit 135 Exit 7 (zero tests)
No coverage 0 0
Dynamic (default) 6 10
Static 0 0

Linux counterpart of #249 (this is the isolation run suggested there); possibly related to #232 / #238.

Activity

  1. adeutscher commented on Oct 25, 2026

    @adeutscher

    I'm running into Exit Code 135 problems as well, and I think my problems are also MTP-based.

    • Env: Rocky Linux 10 Minimal container running an Azure DevOps agent, .NET 10.0.13, dotnet-coverage 18.12.0, xunit.v3 4.0.2.
    • Command: dotnet coverage collect --session-id <id> "dotnet test <sln> --no-build -c Release --report-xunit-xml --results-directory artifacts/ci" -f xml -o coverage.cobertura.xml

    I'm testing a band-aid for this by setting a limit on parallel jobs by adding --max-parallel-test-modules 1 to the inner dotnet test call. Not super-ideal, but it beats all the crashes. Early results look good (zero crashes after a bunch of consecutive runs of the pipeline), but on the other hand this fix is new this afternoon. Time will tell.

  2. ivanball commented on Nov 24, 2026

    @ivanball

    Root cause from two core dumps and an strace, in case it helps. Same symptom here (exit 135, Zero tests ran, a random first-wave module) with dotnet-coverage 18.11.0, and it reproduces with 18.12.0. libCoverageInstrumentationMethod.so is byte-identical between the two (md5 f613db023a87f939cd49bef2092a05c8). Environment: GitHub-hosted ubuntu-latest, and locally in mcr.microsoft.com/dotnet/sdk:11.0 limited to 4 CPUs / 16 GB; .NET 10.0.15 and 11.0.0 hosts, MTP with xUnit v3, about 25 test modules under one dotnet-coverage collect session with default dynamic instrumentation.

    Crash site (both dumps)

    • SIGBUS, si_code=2 (BUS_ADRERR), at a page-aligned address (the mapping base)
    • vanguard::runtime::CInstrumentationMethod::InitializeModuleFromSharedMemoryUnix+168 (movzwl (%rax),%r12d) in libCoverageInstrumentationMethod.so
    • called from OnModuleLoaded <- CProfilerManager::ModuleAttachedToAssembly in libInstrumentationEngine.so, while the host is starting

    What strace (-f -tt) shows
    All hosts of one session share one /tmp/CodeCoverage.<session>.d<guid> file per module. When two hosts load the same module at about the same time, the file is created twice: openat(O_CREAT), ftruncate(fd, 0), fallocate, ftruncate(fd, N). A host that already passed its fstat size check and mapped the file then reads page 0 after the second creator truncated it to 0 bytes, and gets SIGBUS. In one traced run, 7 of 321 module files were re-created like this. With --max-parallel-test-modules 1, 0 of 321 were, which matches the workaround in the comment above. I did not test static instrumentation, but if that path does not create these files concurrently at host startup, it would explain why the original report saw no crashes with it.

    Possible fix direction: create each module file exactly once per session (for example O_EXCL plus a ready marker, or an advisory lock around create-and-size), or give each host a private mapping.

    I can share the dumps and strace captures if useful.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions