Skip to content

[v3] "returned TLS index was too high" due to incorrect interpretation of TlsAlloc return value #1359

Closed

Description

@NarutoUA

Branch: main3

On my machine, mimalloc initialization fails with error returned TLS index was too high (1027002)

Based on mi_win_tls_slot_alloc, TlsAlloc return value is treated as index to zero-based array, despite Microsoft Docs tells you the opposite:

The value of the TLS index should be treated as an opaque value; do not assume that it is an index into a zero-based array.

Activity

  1. changed the title [-]"returned TLS index was too high" due to incorrect interpretation of TlsAlloc return value[/-] [+][v3] "returned TLS index was too high" due to incorrect interpretation of TlsAlloc return value[/+] on Aug 6, 2026
  2. NarutoUA commented on Aug 6, 2026

    @NarutoUA
    Author

    I had my application added to "Application Verifier" with TLS checks enabled, which made TlsAlloc return huge value.

  3. daanx commented on Aug 8, 2026

    @daanx
    Collaborator

    Yes, for the fast win32 TLS model we assume the standard TlsAlloc implementation. This is quite unlikely to ever change though :-)
    But if you want to stay fully standard, just pass -DMI_TLS_MODEL_LOCAL=ON and mimalloc will use standard thread local variables without using TlsAlloc. Let me know how it goes.

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