Commit 1e0fba3
committed
GH-49272: [C++][CI] Fix intermittent segfault in arrow-json-test on MinGW
MinGW's __emutls implementation for C++ thread_local has known race
conditions during thread creation. When ThreadPool::LaunchWorkersUnlocked
creates a new worker thread, the thread writes to the thread_local
current_thread_pool_ variable. If __emutls hasn't finished initializing
TLS for the new thread, this dereferences an invalid pointer, causing
a segfault.
Replace thread_local with native Win32 TLS API (TlsAlloc/TlsGetValue/
TlsSetValue) on MinGW to bypass the buggy __emutls emulation.
Non-MinGW platforms continue using standard thread_local.
Also add a stress test (MultipleChunksParallelStress) that runs parallel
JSON reading 20 times to help expose intermittent threading races.1 parent cbe2618 commit 1e0fba3
2 files changed
+60
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
293 | 318 | | |
294 | 319 | | |
295 | 320 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
630 | 632 | | |
631 | 633 | | |
632 | 634 | | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
633 | 662 | | |
634 | 663 | | |
635 | | - | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
636 | 669 | | |
637 | 670 | | |
638 | 671 | | |
| |||
641 | 674 | | |
642 | 675 | | |
643 | 676 | | |
644 | | - | |
| 677 | + | |
645 | 678 | | |
646 | 679 | | |
647 | 680 | | |
| |||
0 commit comments