Skip to content

Fix "access violation" failures that have appeared in new windows builds by disabling compiler optimization on windows#1077

Merged
Strilanc merged 168 commits into
mainfrom
debugwindowsfailures
Jun 27, 2026
Merged

Fix "access violation" failures that have appeared in new windows builds by disabling compiler optimization on windows#1077
Strilanc merged 168 commits into
mainfrom
debugwindowsfailures

Conversation

@Strilanc

@Strilanc Strilanc commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

The root cause was a compiler autovectorization bug. Turning off optimizations will hurt performance but at least make the code not totally broken.

Reproduction of the bug in a simpler instance:

#include <cstdint>
#include <iostream>

uint64_t repro() {
    uint32_t targets[6]{0, 27, 0, 0, 27, 0};
    uint64_t t = 6;
    for (size_t k = 0; k < 6; k++) {
        if (targets[k] == 27) {
            t -= 2;
        }
    }
    return t;
}

int main() {
    std::cerr << "t=" << repro() << "\n";
    return 0;
}

Go to godbolt, paste the above code, compile it with the compiler x64 msvc v19.51 VS18.6 and flags /O2 and run it and it will print t=8589934594 instead of t=2.

Fixes #1078

@quantumlib quantumlib deleted a comment from review-notebook-app Bot Jun 26, 2026
@Strilanc Strilanc changed the title [WIP] Debug windows failures Fix "access violation" failures that have appeared in new windows builds Jun 27, 2026
@Strilanc Strilanc changed the title Fix "access violation" failures that have appeared in new windows builds Fix "access violation" failures that have appeared in new windows builds by changing /O2 to /O0 Jun 27, 2026
@Strilanc Strilanc changed the title Fix "access violation" failures that have appeared in new windows builds by changing /O2 to /O0 Fix "access violation" failures that have appeared in new windows builds by disabling compiler optimization on windows Jun 27, 2026
@Strilanc Strilanc enabled auto-merge (squash) June 27, 2026 04:34
@Strilanc Strilanc merged commit b2ab44b into main Jun 27, 2026
56 checks passed
@Strilanc Strilanc deleted the debugwindowsfailures branch June 27, 2026 04:38
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.

Debug why CI windows builds are suddenly failing with an access violation

1 participant