llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.61k stars 11.82k forks source link

ThreadPoolExecutor/libsystem_pthread.dylib-related unit test crashes on ARM macOS Big Sur #75401

Open danpetry opened 10 months ago

danpetry commented 10 months ago

I'm seeing crashes in the following unit tests, with the following stack traces, on macOS Big Sur, but not Ventura. MacOSX11.1 SDK and clang 14.0.6 was used to compile:

                   INFO   [ RUN      ] ConcurrentHashTableTest.AddStringMultiplueEntriesWithResize                                                         
                   INFO    #0 0x0000000104e6c994 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0x144994)                            
                   INFO    #1 0x0000000104e6abf0 llvm::sys::RunSignalHandlers() (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0x142bf0)            
                   INFO    #2 0x0000000104e6d084 SignalHandler(int) (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0x145084)                                                             
                   INFO    #3 0x000000019e8cec44 (/usr/lib/system/libsystem_platform.dylib+0x180336c44)                                                      
                   INFO    #4 0x000000010426cfbc std::__1::__function::__func<(anonymous namespace)::ConcurrentHashTableTest_AddStringMultiplueEntriesWithResize_Test::TestBody()::$_2, std::__1::allocator<(anonymous
                          namespace)::ConcurrentHashTableTest_AddStringMultiplueEntriesWithResize_Test::TestBody()::$_2>, void ()>::operator()() (/private$SRC_DIR/build/unittests/ADT/./ADTTests+0x10020cfbc)
                   INFO    #5 0x0000000104decf08 std::__1::__function::__func<llvm::parallel::TaskGroup::spawn(std::__1::function<void ()>, bool)::$_0,
                          std::__1::allocator<llvm::parallel::TaskGroup::spawn(std::__1::function<void ()>, bool)::$_0>, void ()>::operator()() (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0xc4f08)
                   INFO    #6 0x0000000104debebc llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::work(llvm::ThreadPoolStrategy, unsigned int) (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0xc3ebc)
                   INFO    #7 0x0000000104debc10 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >,          
                          llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::ThreadPoolExecutor(llvm::ThreadPoolStrategy)::'lambda'()> >(void*) (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0xc3c10)
                   INFO    #8 0x000000019e883878 (/usr/lib/system/libsystem_pthread.dylib+0x1802eb878)                                                                                
                   INFO    #9 0x000000019e87e5e0 (/usr/lib/system/libsystem_pthread.dylib+0x1802e65e0) 
                  INFO   [ RUN      ] ConcurrentHashTableTest.AddStringEntries                                                              
                   INFO    #0 0x0000000105ce0994 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0x144994)
                   INFO    #1 0x0000000105cdebf0 llvm::sys::RunSignalHandlers() (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0x142bf0)                  
                   INFO    #2 0x0000000105ce1084 SignalHandler(int) (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0x145084)
                   INFO    #3 0x000000019e8cec44 (/usr/lib/system/libsystem_platform.dylib+0x180336c44)                   
                   INFO    #4 0x0000000104ffecdc llvm::ConcurrentHashTableByPtr<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, (anonymous namespace)::String,
                          llvm::parallel::PerThreadAllocator<llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul, 128ul> >, llvm::ConcurrentHashTableInfoByPtr<std::__1::basic_string<char,
                          std::__1::char_traits<char>, std::__1::allocator<char> >, (anonymous namespace)::String, llvm::parallel::PerThreadAllocator<llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul,
                          4096ul, 128ul> > > >::insert(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (/private$SRC_DIR/build/unittests/ADT/./ADTTests+0x10020acdc)
                   INFO    #5 0x0000000104ffdb4c std::__1::__function::__func<(anonymous namespace)::ConcurrentHashTableTest_AddStringEntries_Test::TestBody()::$_0, std::__1::allocator<(anonymous
                          namespace)::ConcurrentHashTableTest_AddStringEntries_Test::TestBody()::$_0>, void ()>::operator()() (/private$SRC_DIR/build/unittests/ADT/./ADTTests+0x100209b4c)
                   INFO    #6 0x0000000105c60f08 std::__1::__function::__func<llvm::parallel::TaskGroup::spawn(std::__1::function<void ()>, bool)::$_0,                                        
                          std::__1::allocator<llvm::parallel::TaskGroup::spawn(std::__1::function<void ()>, bool)::$_0>, void ()>::operator()() (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0xc4f08)
                   INFO    #7 0x0000000105c5febc llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::work(llvm::ThreadPoolStrategy, unsigned int) (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0xc3ebc)
                   INFO    #8 0x0000000105c5ff84 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >,
                          llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::ThreadPoolExecutor(llvm::ThreadPoolStrategy)::'lambda'()::operator()() const::'lambda'()> >(void*)                       
                          (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0xc3f84)                                                                                                                       
                   INFO    #9 0x000000019e883878 (/usr/lib/system/libsystem_pthread.dylib+0x1802eb878)                                                                                         
                   INFO   #10 0x000000019e87e5e0 (/usr/lib/system/libsystem_pthread.dylib+0x1802e65e0)
                  INFO   [ RUN      ] PerThreadBumpPtrAllocatorTest.Simple                                                                          
                   INFO    #0 0x0000000103c04994 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0x144994)                            
                   INFO    #1 0x0000000103c02bf0 llvm::sys::RunSignalHandlers() (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0x142bf0)
                   INFO    #2 0x0000000103c05084 SignalHandler(int) (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0x145084)
                   INFO    #3 0x000000019e8cec44 (/usr/lib/system/libsystem_platform.dylib+0x180336c44)     
                   INFO    #4 0x0000000102d03d28 std::__1::__function::__func<(anonymous namespace)::PerThreadBumpPtrAllocatorTest_Simple_Test::TestBody()::$_0, std::__1::allocator<(anonymous
                          namespace)::PerThreadBumpPtrAllocatorTest_Simple_Test::TestBody()::$_0>, void ()>::operator()() (/private$SRC_DIR/build/unittests/Support/./SupportTests+0x10027fd28)
                   INFO    #5 0x0000000103b84f08 std::__1::__function::__func<llvm::parallel::TaskGroup::spawn(std::__1::function<void ()>, bool)::$_0,
                          std::__1::allocator<llvm::parallel::TaskGroup::spawn(std::__1::function<void ()>, bool)::$_0>, void ()>::operator()() (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0xc4f08)
                   INFO    #6 0x0000000103b83ebc llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::work(llvm::ThreadPoolStrategy, unsigned int) (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0xc3ebc)
                   INFO    #7 0x0000000103b83f84 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >,
                          llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::ThreadPoolExecutor(llvm::ThreadPoolStrategy)::'lambda'()::operator()() const::'lambda'()> >(void*)
                          (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0xc3f84)
                   INFO    #8 0x000000019e883878 (/usr/lib/system/libsystem_pthread.dylib+0x1802eb878)
                   INFO    #9 0x000000019e87e5e0 (/usr/lib/system/libsystem_pthread.dylib+0x1802e65e0)
                   INFO   [ RUN      ] PerThreadBumpPtrAllocatorTest.ParallelAllocation                        
                   INFO    #0 0x00000001018f4994 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0x144994)
                   INFO    #1 0x00000001018f2bf0 llvm::sys::RunSignalHandlers() (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0x142bf0)
                   INFO    #2 0x00000001018f5084 SignalHandler(int) (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0x145084)
                   INFO    #3 0x000000019e8cec44 (/usr/lib/system/libsystem_platform.dylib+0x180336c44)   
                   INFO    #4 0x0000000100b24cf4 void llvm::function_ref<void (unsigned long)>::callback_fn<(anonymous namespace)::PerThreadBumpPtrAllocatorTest_ParallelAllocation_Test::TestBody()::$_1>(long,
                          unsigned long) (/private$SRC_DIR/build/unittests/Support/./SupportTests+0x100280cf4)
                   INFO    #5 0x0000000101875198 std::__1::__function::__func<llvm::parallelFor(unsigned long, unsigned long, llvm::function_ref<void (unsigned long)>)::$_2,
                          std::__1::allocator<llvm::parallelFor(unsigned long, unsigned long, llvm::function_ref<void (unsigned long)>)::$_2>, void ()>::operator()()
                          (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0xc5198)
                   INFO    #6 0x0000000101874f08 std::__1::__function::__func<llvm::parallel::TaskGroup::spawn(std::__1::function<void ()>, bool)::$_0,
                          std::__1::allocator<llvm::parallel::TaskGroup::spawn(std::__1::function<void ()>, bool)::$_0>, void ()>::operator()() (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0xc4f08)
                   INFO    #7 0x0000000101873ebc llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::work(llvm::ThreadPoolStrategy, unsigned int) (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0xc3ebc)
                   INFO    #8 0x0000000101873c10 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >,
                          llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::ThreadPoolExecutor(llvm::ThreadPoolStrategy)::'lambda'()> >(void*) (/private$SRC_DIR/build/lib/libLLVM-17.dylib+0xc3c10)
                   INFO    #9 0x000000019e883878 (/usr/lib/system/libsystem_pthread.dylib+0x1802eb878)       
                   INFO   #10 0x000000019e87e5e0 (/usr/lib/system/libsystem_pthread.dylib+0x1802e65e0)

Is this a platform or toolchain issue, or a bug? Please let me know if you need any further info.

danpetry commented 9 months ago

ping, any possibility of attention here :) ?

to268 commented 8 months ago

Hi, Unfortunately, we can't do anything on our side. It looks like the bug is coming from their version of Clang called Apple Clang (I'm assuming since you are running an old version). Feel free to check if it's the case.

danpetry commented 8 months ago

We're using conda clang 14 from Anaconda main channel. This is seen while building llvm 17 for conda packaging for the same channel. So I guess the same applies - it's probably due to an older version of clang being used to compile? When building a new version of the llvm-project tools, what previous version range of clang is recommended/supported?

to268 commented 8 months ago

I did not know conda clang was a thing. For recommended/supported versions, the latest major stable version is your best bet. Try to do the same thing with the latest version that you can use, and check if the problem has been solved.

to268 commented 8 months ago

It's also weird to use Clang 14 with LLVM 17. It should be the same major version, at least.

danpetry commented 8 months ago

sure. But when building new llvm/clang, clang is required. to break the circular dependency, an older version is needed, or is there something I'm missing?

danpetry commented 8 months ago

the current version of clang in the conda distro is 14, so that's what I'm using. Once llvm and clang 17 is built and packaged, it'll be possible to go back and recompile both with clang 17. I'm just wondering if you have any recommendations for distro maintainers building newer versions of clang. We could use that version of clang from another distro, but what if you're the first one building it? Just wondering if there's any recommendations on an approach here. To clarify, I'm compiling llvm 17 with clang 14, rather than mixing versions in the same toolchain.

to268 commented 8 months ago

You do not need specifically Clang to build any component of the project, you need to have a compiler that support the C++17 standard at least, some other subprojects needs a newer version. We have a documentation page about how to distribute llvm and other subprojects Building a distribution. It looks like an incompatibility with a system library, but I am not quite if it's caused by the library of Big Sur or the conda version is weird. Clang 14 is not too old yet to compile LLVM currently. Maybe you need to try with Apple Clang (even if it's lagging behind a couple of major releases).

danpetry commented 8 months ago

ok, thanks for the info. I'll have a look at that page

to268 commented 8 months ago

Hi, have you resolved the issue?

danpetry commented 8 months ago

Hi Tony, thanks for the heads-up, i haven't managed to look at this in depth yet but I'll update the ticket when I do.