Skip to content

OpenHarmony: csc exits with SIGSEGV (139) compiling a 1.27MB source file #2

Open

Description

@springmin

Summary

csc intermittently dies with signal 11 while compiling the generated 1.27MB Program.cs of ohos-workload/test/maui-platform-verify:

.../Roslyn/Microsoft.CSharp.Core.targets(97,5): error MSB6006: "csc" exited with code 139.

Same command, same SDK, same machine: four consecutive successful builds, then a run where all eight retries crashed.

Repro

cd ohos-workload/test/maui-platform-verify
dotnet restore /p:RestoreSources= /p:NuGetAudit=false
dotnet build --no-restore -m:1 -noconlog -tl:off \
  "-flp:logfile=$PWD/build.log;verbosity=minimal" \
  /p:UseSharedCompilation=false /p:NuGetAudit=false
# intermittently: error MSB6006 ... exited with code 139

Evidence (self-hosted OpenHarmony arm64 runner)

  • green (4x): runs 44231192119, 44287437847, 44296283507, 44437562209 — 826 suite reported checks=826 total=829 floor=809 assert=True
  • red (all 8 retries): run 44458801435 — same job, error MSB6006 ... code 139
  • with prebuilt_826=true the gate is deterministic (run 44479197802).

Notes

Workaround in the gate

Use a prebuilt verify.dll (prebuilt_826=true) so the suite runs without invoking csc on this host.

Activity

  1. springmin commented on Nov 19, 2026

    @springmin
    OwnerAuthor

    More data: disabling analyzers helps but does not eliminate it.

    • Local, canonical path, fresh bin, /p:RunAnalyzers=false /p:TreatWarningsAsErrors=false:
      • baseline rc=0 dll=yes
      • DOTNET_ReadyToRun=0 rc=0 dll=yes
      • DOTNET_TieredPGO=0 rc=0 dll=yes
        (3/3 success, no code 139)
    • Same flags inside the runner (prebuilt_826=false, run 44503217746): still csc ... code 139 once, run failed.

    So the analyzer pass over the 1.27MB source raises the failure rate but the crash is not specific to it; the crash remains intermittent and environment-dependent (runs 4x green / then all-red).

  2. springmin commented on Nov 19, 2026

    @springmin
    OwnerAuthor

    Triage capability check: crash dumps are not produced on this port.

    $ DOTNET_DbgEnableMiniDump=1 DOTNET_DbgMiniDumpType=2 DOTNET_DbgMiniDumpName=.../core.%p dotnet t.dll
    run rc=134            # SIGABRT from the unhandled exception
    $ ls dumps
    (empty)               # no dump written
    

    createdump exists next to the runtime (shared/Microsoft.NETCore.App/11.0.0/createdump), but it only dumps its own parent (createdump --help: "createdump writes a dump of its parent process; a target PID cannot be specified"), so it cannot be used to capture a csc crash.

    Consequence: there is no supported way to get a native stack for the SIGSEGV on this host. Root-causing #2 will need either

    • a dump-capable build of the port (pid-taking createdump), or
    • reproducing on a host with a debugger (lldb/gdb + SOS) available.

    Until then the mitigation stands: run the suite from a prebuilt assembly (prebuilt_826=true).

  3. springmin commented on Nov 19, 2026

    @springmin
    OwnerAuthor

    Route check: ptrace is denied by the sandbox, so external dump/debugger routes are out.

    $ python3 -c "ctypes libc.ptrace(PTRACE_ATTACH, <sibling pid>)"
    attach=-1 errno=13 (Permission denied)
    

    Implications:

    • pid-taking createdump (a cross-process attach) cannot work here, which explains why this port only dumps its own parent: createdump is forked by the crashing process, and a child attaching to its parent is permitted while attaching to an unrelated pid is not.
    • lldb/gdb attach is equally blocked (no debugger installed either).

    So the only in-process option left is the runtime's own crash path. That path is also suspicious: with

    DOTNET_DbgEnableMiniDump=1 DOTNET_DbgMiniDumpType=2 DOTNET_DbgMiniDumpName=.../core.%p
    

    an unhandled exception aborts the process (rc=134) but no dump file is written, even though createdump exists next to the runtime. Worth checking whether the runtime was built with createdump support (CLR_CMAKE_ENABLE_CREATEDUMP) and whether the env-var plumbing reaches createdump on this port.

    Next feasible step: instrument the runtime (stress log) since it is in-process and does not need ptrace.

  4. springmin commented on Nov 19, 2026

    @springmin
    OwnerAuthor

    Route 3 check: the repo cannot build its own runtime on this host.

    $ ./build.sh clr.runtime -c release -arch arm64 /p:FeatureStressLog=true
    Unsupported OS harmonyos detected!
    

    So build.sh (Arcade) refuses to run on HarmonyOS, which means the stress-log variant of the runtime cannot be produced here either.

    Status of all triage routes on this host:

    1. pid-taking createdump — blocked: ptrace returns EPERM for non-descendant pids.
    2. lldb/gdb attach — blocked: same EPERM, and no debugger is installed.
    3. instrumented runtime (stress log) — blocked: build.sh rejects the HarmonyOS host.

    Conclusion: root-causing this crash requires a supported build host (Linux glibc x64/arm64) to produce a runtime with FeatureStressLog=true (or a dump-capable createdump), then deploy that runtime back to the device. On the device itself only the mitigation path is available (prebuilt assembly, prebuilt_826=true).

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