actions / runner

The Runner for GitHub Actions :rocket:
https://github.com/features/actions
MIT License
4.64k stars 892 forks source link

Segmentation Fault with Visual Studio 2022 on GitHub Actions Windows Runners - using C++ thread #3331

Closed pthom closed 2 weeks ago

pthom commented 2 weeks ago

Describe the bug

I have encountered a segmentation fault when running a simple async program compiled with Visual Studio 2022 in release mode on GitHub Actions Windows 2022 runners.

To Reproduce

Ready to use repro

Step by step instructions

  1. Use the following C++ code in your repository:

main.cpp

#include <future>
#include <cstdio>

int main() {
    auto handle = std::async(std::launch::async, []() { return 1; });
    int r = handle.get();
    printf("Result: %d\n", r);
}
  1. Use the following CMakeLists:
cmake_minimum_required(VERSION 3.5)
project("study_ci_thread_fault")
set(CMAKE_CXX_STANDARD 17)
add_executable(main main.cpp)
  1. Use the following GitHub Actions workflow:
name: ci

on: [workflow_dispatch, push, pull_request]

jobs:
  build:
    runs-on: windows-2022
    steps:
      - uses: actions/checkout@main
      - name: Build and Test
        shell: bash
        run: |
          mkdir build
          cd build
          cmake ..
          cmake --build . --config Release
          ./Release/main.exe
  1. Observe the segmentation fault during the test execution.

Expected behavior The async program should run without crashing.

Actual Behavior The program crashes with a segmentation fault.

Runner Version and Platform

windows-2022 (aka windows-latest)

OS of the machine running the runner? Windows

Job Log Output

Run ./build/Release/main.exe
  ./build/Release/main.exe
  shell: C:\Program Files\Git\bin\bash.EXE --noprofile --norc -e -o pipefail {0}
Result: 1

Insights

I posted this as a Stack Overflow question here.

https://stackoverflow.com/questions/78612314/github-runners-issue-with-visual-studio-2022-segmentation-fault-with-the-simple

An helpful comment was given, which may be linked to this issue:

https://stackoverflow.com/questions/78598141/first-stdmutexlock-crashes-in-application-built-with-latest-visual-studio

pthom commented 2 weeks ago

Related issue: https://github.com/actions/runner-images/issues/10004#issuecomment-2156109231

pthom commented 2 weeks ago

The issue was fixed while I was studying it. Closing...

horror-proton commented 2 weeks ago

I didn't see how it was fixed, did they revert the version update in runner-images :thinking:

pthom commented 2 weeks ago

I don't know. I did not receive any information about the fix.