Skip to content

[C++][CI] MinGW GCC 16.1 regression - shared_ptr corruption in multi-threaded tests #49958

Closed

Description

@tadeja

Describe the bug, including details regarding any error messages, version, and platform.

Status: Resolved (May 16). Root cause was GCC bug 125312 15.2->16.1 regression in MinGW's libstdc++.dll (non-inline __exchange_and_add used by atomic shared_ptr ref-counting). Not an Arrow bug.
Fix shipped via MSYS2 rebuild msys2/MINGW-packages#29502 with release 4 mingw-w64-x86_64-gcc-libs-16.1.0-4.

Arrow CI - pin workaround from #49931 reverted with #49945 (merged May 16) and MinGW job passing on then-current MSYS2: https://github.com/apache/arrow/actions/runs/25937291262/job/76296127141#step:5:109
Parent/umbrella: #49948 (closed). Initial diagnosis details in #49961.

On AMD64 Windows MinGW MINGW64 C++ with MSYS2 gcc 15.2 -> 16.1 update (post 2026 April 30: mingw-w64-x86_64-gcc-16.1.0-3 and mingw-w64-x86_64-gcc-libs) two tests started failing every run with std::bad_weak_ptr: arrow-dataset-dataset-writer-test and arrow-dataset-file-test. Also affected, with no dataset code involved: arrow-async-utility-test (heap corruption in PushGenerator.Stress), arrow-threading-utility-test (Timeout), ...
CLANG64 C++ (libc++) and gcc 15.2 are unaffected!

Example CI log

[ RUN      ] TestFileSystemDataset.MultiThreadedWritePersistsOrder
terminate called after throwing an instance of 'std::bad_weak_ptr'
  what():  bad_weak_ptr
...
[ RUN      ] DatasetWriterTestFixture.BatchWriteConcurrent
terminate called after throwing an instance of 'std::bad_weak_ptr'
  what():  bad_weak_ptr

Component(s)

C++, Continuous Integration

Activity

  1. tadeja commented on May 12, 2026

    @tadeja
    MemberAuthor

    Cross-posting from pr for visibility:

    Diagnosed further - this isn't a dataset_writer bug. It looks like lower-level memory corruption, likely a gcc-16/MinGW regression. Keeping workaround of #49931's MSYS2 pin for now, #49945 stays waiting, tracked under #49948.

        Test #62: arrow-dataset-dataset-writer-test ............Exit code 0xc0000374***Exception:   0.30 sec
    ...
        Test #62: arrow-dataset-dataset-writer-test ............   Passed    4.85 sec
    ...
    The following tests FAILED:
    	 41 - arrow-async-utility-test (Exit code 0xc0000374)   arrow-tests unittest
    	 44 - arrow-threading-utility-test (Timeout)            arrow-tests unittest
    	 65 - arrow-dataset-file-test (Failed)                  arrow_dataset unittest
    	 78 - arrow-flight-test (Failed)                        arrow_flight unittest
    Error: Process completed with exit code 8.
    • Independent reproducers without dataset_writer are: arrow-async-utility-test always dies at PushGenerator.Stress and arrow-threading-utility-test always times out. Both fine on CLANG64/libc++ and on gcc‑15.2. Only gcc 15.2->gcc 16.1 is affected.
  2. changed the title [-][C++][Dataset] std::bad_weak_ptr in multi-threaded writer tests on MinGW gcc-16[/-] [+][C++][CI] MinGW Gcc 15.2->16.1 toolchain regression - memory corruption in multi-threaded tests[/+] on May 12, 2026
  3. kou commented on May 12, 2026

    @kou
    Member

    Thanks for debugging this. If this is a MinGW GCC 16.1 problem, it's better that we report it to the upstream. Can we create a (small) program code that reproduces this?

  4. tadeja commented on May 14, 2026

    @tadeja
    MemberAuthor

    @kou I've reported upstream gcc - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125312

    I have repro set of CI logs listed in comment from yesterday and with more debug from today.

    Maybe we could open an issue also in MINGW-packages for posterity (this example issue got closed immediately).

  5. kou commented on May 14, 2026

    @kou
    Member

    Great! Thanks!

  6. changed the title [-][C++][CI] MinGW Gcc 15.2->16.1 toolchain regression - memory corruption in multi-threaded tests[/-] [+][C++][CI] MinGW GCC 16.1 regression - shared_ptr corruption in multi-threaded tests[/+] on May 15, 2026
  7. tadeja commented on May 15, 2026

    @tadeja
    MemberAuthor
  8. kou commented on May 15, 2026

    @kou
    Member

    Great!!!

  9. added a commit that references this issue on May 16, 2026
  10. tadeja commented on May 19, 2026

    @tadeja
    MemberAuthor

    Closing as resolved by gcc#125312 -> msys2/MINGW-packages#29502 (merged May 15) and then #49945 (merged May 16).
    Arrow tests now pass on current MSYS2: https://github.com/apache/arrow/actions/runs/25937291262/job/76296127141#step:5:109

    Thanks @kou for the nudge to take this upstream!

  11. added a commit that references this issue on May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions