Skip to content

[CoreCLR] Complete startup-aware lock initialization#12219

Open
jonathanpeppers wants to merge 3 commits into
mainfrom
jonathanpeppers-fix-coreclr-startup-locking
Open

[CoreCLR] Complete startup-aware lock initialization#12219
jonathanpeppers wants to merge 3 commits into
mainfrom
jonathanpeppers-fix-coreclr-startup-locking

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Context

Mono marks runtime startup complete at the end of successful initialization by calling MonodroidState::mark_startup_done().

CoreCLR had the same MonodroidState implementation, but its initialization function returned without calling mark_startup_done(). Consequently, StartupAwareLock continued treating the process as single-threaded startup and never acquired its mutexes after initialization.

This affects synchronization for lazy assembly decompression and DSO handle initialization.

Change

Call MonodroidState::mark_startup_done() at the end of successful CoreCLR managed initialization, after returned JNI function pointers are published and final startup timing events complete. This mirrors Mono's placement and comment style; Mono has no comment on the transition, so none is added here.

Testing

  • Compiled the startup-state and lock headers with the installed NDK C++23 compiler for arm64-v8a, armeabi-v7a, x86_64, and x86.
  • Full repository native/device validation could not run because the repository SDK preparation failed with insufficient disk space on C:.

  • Useful description of why the change is necessary.
  • Links to issues fixed — no issue is associated with this audit finding.
  • Unit tests — no focused native unit-test harness covers this lifecycle transition.

Mark CoreCLR startup complete after managed runtime initialization so lazy assembly and DSO operations use their synchronization primitives. Add a concurrent cold-start assembly decompression stress test.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7bf1a651-5488-4ef9-92e6-863f27e23da5
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7bf1a651-5488-4ef9-92e6-863f27e23da5
Remove the CoreCLR-only comment so the startup completion call mirrors the existing Mono implementation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7bf1a651-5488-4ef9-92e6-863f27e23da5
Copilot AI review requested due to automatic review settings July 23, 2026 21:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ensures CoreCLR’s runtime initialization correctly transitions out of “startup in progress” so StartupAwareLock begins acquiring mutexes after successful managed initialization, matching Mono’s lifecycle behavior and fixing missing synchronization for post-startup lazy init paths.

Changes:

  • Include runtime-base/monodroid-state.hh in CoreCLR host initialization code.
  • Call MonodroidState::mark_startup_done () at the end of successful Java_mono_android_Runtime_initInternal.

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.

2 participants