Skip to content

[mono] JIT inline access to [ThreadStatic] fields doesn't run the class constructor #136592

Open

Description

@lewing

Accessing a [ThreadStatic] field of a class with an explicit static constructor doesn't run the constructor in Mono JIT code. src/mono/mono/mini/method-to-ir.c emits the inline TLS access (is_special_static && thread_ins) without emit_class_init, unlike the other static-field paths.

Repro: src/tests/JIT/Regression_ro_2/Runtime_136480.cs returns (0, 0, 0) instead of (0, 0, 1) on the mono linux/windows/osx runtime-test lanes (build 1652778).

Found while fixing the CoreCLR counterpart, #136480 / #136535.

Note

This issue was drafted with GitHub Copilot.

Activity

  1. dotnet-policy-service commented on Oct 28, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @steveisok, @vitek-karas
    See info in area-owners.md if you want to be subscribed.

  2. added a commit that references this issue on Oct 28, 2026
  3. added
    untriaged
    on Oct 28, 2026
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

    area-Codegen-JIT-monountriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions