Skip to content

Illegal instruction on old CPU and v3.2.x or 3.3.x when compiling with VS2026 #1291

@lrms

Description

@lrms

When using mimalloc-redirect.dll on an Intel Xeon E5410 CPU* my applications crashes when loading with mimalloc versions 3.3.x (also 3.2.8), but not 2.3.x nor 1.9.x. Problem happens both in x86 and x64.

With mimalloc redirection disabled the same app loads successfully. With it enabled it crashes with exception C00000142 (DLL init failed) being show in the GUI. But looking in Windows Error Reporting we can find the real error - C000001D (illegal instruction) inside mimalloc-override.dll.

Browsing the sources of both versions, it seems the difference is the use of the __pocnt intrinsic (by design the VS2026 compiler will emit the POPCNT instruction no matter what architecture is set in vcxproj - even using "/arch:IA32").
I also noticed the bit for the instruction support is already tested inside mimalloc code (bool _mi_cpu_has_popcnt) but is not used (in version 3.3.2, at least). It seems a runtime or compile time (check against MSVC2026) workaround maybe be need if VS2026 support is desirable and support for CPUs without POPCNT is also desirable.

For reference, I am compiling mimalloc with VS2026 v18.5.2 (but also had the problem with previous versions of it). I did compile also mimalloc 2.3.1 and 2.3.2 and both run fine when compiled with VS2026. For me its strange that mimalloc machinery seems not to use __popcnt when compiled with VS2022, although the intrinsic already existed in its compiler version (by docs, at least).

*This CPU supports up to SEE4.1.

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