axmolengine / axmol

Axmol Engine – A Multi-platform Engine for Desktop, XBOX (UWP) and Mobile games. (A fork of Cocos2d-x-4.0)
https://axmol.dev
MIT License
922 stars 205 forks source link

cpp-tests - thread sanitizer - many races/crashes #1752

Closed crazyhappygame closed 3 months ago

crazyhappygame commented 8 months ago
  1. Enable thread sanitizer. Add on the top of CMakeLists.txt
    
    cmake_minimum_required(VERSION 3.22)

project(axmol)

add_compile_options(-fsanitize=thread) add_link_options(-fsanitize=thread)

2. build run cpp-tests
3. Many crashes
e.g.: Press "Start AutoTest" crash
4. Many races detected
Go  to FileUtlis
Go to "New Audio Engine" play music
Example:

WARNING: ThreadSanitizer: data race (pid=8716) Read of size 8 at 0x000114b03a18 by main thread:

0 std::1::vector<std::1::function<void ()>, std::1::allocator<std::1::function<void ()>>>::empty[abi:v160006]() const vector:552 (cpp-tests:arm64+0x101ec4e24)

#1 ax::Scheduler::update(float) Scheduler.cpp:855 (cpp-tests:arm64+0x102014d94)
#2 ax::Director::drawScene() Director.cpp:289 (cpp-tests:arm64+0x101f527e8)
#3 ax::Director::mainLoop() Director.cpp:1547 (cpp-tests:arm64+0x101f59da0)
#4 ax::Application::run() Application-mac.mm:76 (cpp-tests:arm64+0x10236560c)
#5 main main.cpp:32 (cpp-tests:arm64+0x1019a6ce4)

Previous write of size 8 at 0x000114b03a18 by thread T18 (mutexes: write M0):

0 std::__1::enable_if<is_move_constructible<std::1::function<void ()>*>::value && is_move_assignable<std::1::function<void ()>>::value, void>::type std::1::swap[abi:v160006]<std::1::function<void ()>>(std::1::function<void ()>*&, std::1::function<void ()>*&) swap.h:40 (cpp-tests:arm64+0x101e96780)

#1 std::__1::vector<std::__1::function<void ()>, std::__1::allocator<std::__1::function<void ()>>>::__swap_out_circular_buffer(std::__1::__split_buffer<std::__1::function<void ()>, std::__1::allocator<std::__1::function<void ()>>&>&) vector:920 (cpp-tests:arm64+0x101e95ce0)
#2 void std::__1::vector<std::__1::function<void ()>, std::__1::allocator<std::__1::function<void ()>>>::__emplace_back_slow_path<std::__1::function<void ()>>(std::__1::function<void ()>&&) vector:1584 (cpp-tests:arm64+0x102017524)
#3 std::__1::function<void ()>& std::__1::vector<std::__1::function<void ()>, std::__1::allocator<std::__1::function<void ()>>>::emplace_back<std::__1::function<void ()>>(std::__1::function<void ()>&&) vector:1603 (cpp-tests:arm64+0x10201433c)
#4 ax::Scheduler::runOnAxmolThread(std::__1::function<void ()>) Scheduler.cpp:722 (cpp-tests:arm64+0x10201423c)
#5 ax::AsyncTaskPool::ThreadTasks::ThreadTasks()::'lambda'()::operator()() const AsyncTaskPool.h:137 (cpp-tests:arm64+0x101ee8d9c)
#6 decltype(std::declval<ax::AsyncTaskPool::ThreadTasks::ThreadTasks()::'lambda'()>()()) std::__1::__invoke[abi:v160006]<ax::AsyncTaskPool::ThreadTasks::ThreadTasks()::'lambda'()>(ax::AsyncTaskPool::ThreadTasks::ThreadTasks()::'lambda'()&&) invoke.h:394 (cpp-tests:arm64+0x101ee8b48)
#7 void std::__1::__thread_execute[abi:v160006]<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, ax::AsyncTaskPool::ThreadTasks::ThreadTasks()::'lambda'()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, ax::AsyncTaskPool::ThreadTasks::ThreadTasks()::'lambda'()>&, std::__1::__tuple_indices<>) thread:288 (cpp-tests:arm64+0x101ee8af4)
#8 void* std::__1::__thread_proxy[abi:v160006]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, ax::AsyncTaskPool::ThreadTasks::ThreadTasks()::'lambda'()>>(void*) thread:299 (cpp-tests:arm64+0x101ee8588)

As if synchronized via sleep:

0 nanosleep :264457860 (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x2f618)

#1 std::__1::this_thread::sleep_for(std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l>> const&) <null>:264457860 (libc++.1.dylib:arm64e+0x22b88)
#2 main main.cpp:32 (cpp-tests:arm64+0x1019a6ce4)

Location is heap block of size 368 at 0x000114b03900 allocated by main thread:

0 operator new(unsigned long) :264457860 (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x84420)

#1 ax::Director::init() Director.cpp:120 (cpp-tests:arm64+0x101f50280)
#2 ax::Director::getInstance() Director.cpp:95 (cpp-tests:arm64+0x101f5010c)
#3 ax::Configuration::loadConfigFile(std::__1::basic_string_view<char, std::__1::char_traits<char>>) Configuration.cpp:401 (cpp-tests:arm64+0x101ef5a58)
#4 AppDelegate::applicationDidFinishLaunching() AppDelegate.cpp:64 (cpp-tests:arm64+0x1001bb8f0)
#5 ax::Application::run() Application-mac.mm:57 (cpp-tests:arm64+0x10236554c)
#6 main main.cpp:32 (cpp-tests:arm64+0x1019a6ce4)

Mutex M0 (0x000114b03a30) created at:

0 pthread_mutex_lock :264457860 (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x3cf8c)

#1 std::__1::mutex::lock() <null>:264457860 (libc++.1.dylib:arm64e+0x16710)
#2 std::__1::lock_guard<std::__1::mutex>::lock_guard[abi:v160006](std::__1::mutex&) __mutex_base:94 (cpp-tests:arm64+0x101e934b8)
#3 ax::Scheduler::runOnAxmolThread(std::__1::function<void ()>) Scheduler.cpp:721 (cpp-tests:arm64+0x102014228)
#4 ax::AudioEngineImpl::_play2d(ax::AudioCache*, int) AudioEngineImpl.cpp:595 (cpp-tests:arm64+0x101ec29b4)
#5 decltype(*std::declval<ax::AudioEngineImpl*&>().*std::declval<void (ax::AudioEngineImpl::*&)(ax::AudioCache*, int)>()(std::declval<ax::AudioCache*&>(), std::declval<int&>())) std::__1::__invoke[abi:v160006]<void (ax::AudioEngineImpl::*&)(ax::AudioCache*, int), ax::AudioEngineImpl*&, ax::AudioCache*&, int&, void>(void (ax::AudioEngineImpl::*&)(ax::AudioCache*, int), ax::AudioEngineImpl*&, ax::AudioCache*&, int&) invoke.h:359 (cpp-tests:arm64+0x101edf75c)
#6 std::__1::__bind_return<void (ax::AudioEngineImpl::*)(ax::AudioCache*, int), std::__1::tuple<ax::AudioEngineImpl*, ax::AudioCache*, int>, std::__1::tuple<>, __is_valid_bind_return<void (ax::AudioEngineImpl::*)(ax::AudioCache*, int), std::__1::tuple<ax::AudioEngineImpl*, ax::AudioCache*, int>, std::__1::tuple<>>::value>::type std::__1::__apply_functor[abi:v160006]<void (ax::AudioEngineImpl::*)(ax::AudioCache*, int), std::__1::tuple<ax::AudioEngineImpl*, ax::AudioCache*, int>, 0ul, 1ul, 2ul, std::__1::tuple<>>(void (ax::AudioEngineImpl::*&)(ax::AudioCache*, int), std::__1::tuple<ax::AudioEngineImpl*, ax::AudioCache*, int>&, std::__1::__tuple_indices<0ul, 1ul, 2ul>, std::__1::tuple<>&&) bind.h:263 (cpp-tests:arm64+0x101edf62c)
#7 std::__1::__bind_return<void (ax::AudioEngineImpl::*)(ax::AudioCache*, int), std::__1::tuple<ax::AudioEngineImpl*, ax::AudioCache*, int>, std::__1::tuple<>, __is_valid_bind_return<void (ax::AudioEngineImpl::*)(ax::AudioCache*, int), std::__1::tuple<ax::AudioEngineImpl*, ax::AudioCache*, int>, std::__1::tuple<>>::value>::type std::__1::__bind<void (ax::AudioEngineImpl::*)(ax::AudioCache*, int), ax::AudioEngineImpl*, ax::AudioCache*&, int&>::operator()[abi:v160006]<>() bind.h:295 (cpp-tests:arm64+0x101edf574)
#8 decltype(std::declval<std::__1::__bind<void (ax::AudioEngineImpl::*)(ax::AudioCache*, int), ax::AudioEngineImpl*, ax::AudioCache*&, int&>&>()()) std::__1::__invoke[abi:v160006]<std::__1::__bind<void (ax::AudioEngineImpl::*)(ax::AudioCache*, int), ax::AudioEngineImpl*, ax::AudioCache*&, int&>&>(std::__1::__bind<void (ax::AudioEngineImpl::*)(ax::AudioCache*, int), ax::AudioEngineImpl*, ax::AudioCache*&, int&>&) invoke.h:394 (cpp-tests:arm64+0x101edf514)
#9 void std::__1::__invoke_void_return_wrapper<void, true>::__call<std::__1::__bind<void (ax::AudioEngineImpl::*)(ax::AudioCache*, int), ax::AudioEngineImpl*, ax::AudioCache*&, int&>&>(std::__1::__bind<void (ax::AudioEngineImpl::*)(ax::AudioCache*, int), ax::AudioEngineImpl*, ax::AudioCache*&, int&>&) invoke.h:487 (cpp-tests:arm64+0x101edf478)
#10 std::__1::__function::__alloc_func<std::__1::__bind<void (ax::AudioEngineImpl::*)(ax::AudioCache*, int), ax::AudioEngineImpl*, ax::AudioCache*&, int&>, std::__1::allocator<std::__1::__bind<void (ax::AudioEngineImpl::*)(ax::AudioCache*, int), ax::AudioEngineImpl*, ax::AudioCache*&, int&>>, void ()>::operator()[abi:v160006]() function.h:185 (cpp-tests:arm64+0x101edf424)
#11 std::__1::__function::__func<std::__1::__bind<void (ax::AudioEngineImpl::*)(ax::AudioCache*, int), ax::AudioEngineImpl*, ax::AudioCache*&, int&>, std::__1::allocator<std::__1::__bind<void (ax::AudioEngineImpl::*)(ax::AudioCache*, int), ax::AudioEngineImpl*, ax::AudioCache*&, int&>>, void ()>::operator()() function.h:356 (cpp-tests:arm64+0x101edd6d4)
#12 std::__1::__function::__value_func<void ()>::operator()[abi:v160006]() const function.h:510 (cpp-tests:arm64+0x1019d556c)
#13 std::__1::function<void ()>::operator()() const function.h:1156 (cpp-tests:arm64+0x1019d3674)
#14 ax::AudioCache::invokingPlayCallbacks() AudioCache.cpp:372 (cpp-tests:arm64+0x101e930d8)
#15 ax::AudioCache::readDataTask(unsigned int) AudioCache.cpp:336 (cpp-tests:arm64+0x101e92d9c)
#16 ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1::operator()() const AudioEngineImpl.cpp:516 (cpp-tests:arm64+0x101ed9e68)
#17 decltype(std::declval<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1&>()()) std::__1::__invoke[abi:v160006]<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1&>(ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1&) invoke.h:394 (cpp-tests:arm64+0x101ed9d78)
#18 void std::__1::__invoke_void_return_wrapper<void, true>::__call<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1&>(ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1&) invoke.h:487 (cpp-tests:arm64+0x101ed9cdc)
#19 std::__1::__function::__alloc_func<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1, std::__1::allocator<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1>, void ()>::operator()[abi:v160006]() function.h:185 (cpp-tests:arm64+0x101ed9c88)
#20 std::__1::__function::__func<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1, std::__1::allocator<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1>, void ()>::operator()() function.h:356 (cpp-tests:arm64+0x101ed7b80)
#21 std::__1::__function::__value_func<void ()>::operator()[abi:v160006]() const function.h:510 (cpp-tests:arm64+0x1019d556c)
#22 std::__1::function<void ()>::operator()() const function.h:1156 (cpp-tests:arm64+0x1019d3674)
#23 ax::AudioEngine::AudioEngineThreadPool::threadFunc() AudioEngine.cpp:126 (cpp-tests:arm64+0x101ea971c)
#24 decltype(*std::declval<ax::AudioEngine::AudioEngineThreadPool*&>().*std::declval<void (ax::AudioEngine::AudioEngineThreadPool::*&)()>()()) std::__1::__invoke[abi:v160006]<void (ax::AudioEngine::AudioEngineThreadPool::*&)(), ax::AudioEngine::AudioEngineThreadPool*&, void>(void (ax::AudioEngine::AudioEngineThreadPool::*&)(), ax::AudioEngine::AudioEngineThreadPool*&) invoke.h:359 (cpp-tests:arm64+0x101eadb04)
#25 std::__1::__bind_return<void (ax::AudioEngine::AudioEngineThreadPool::*)(), std::__1::tuple<ax::AudioEngine::AudioEngineThreadPool*>, std::__1::tuple<>, __is_valid_bind_return<void (ax::AudioEngine::AudioEngineThreadPool::*)(), std::__1::tuple<ax::AudioEngine::AudioEngineThreadPool*>, std::__1::tuple<>>::value>::type std::__1::__apply_functor[abi:v160006]<void (ax::AudioEngine::AudioEngineThreadPool::*)(), std::__1::tuple<ax::AudioEngine::AudioEngineThreadPool*>, 0ul, std::__1::tuple<>>(void (ax::AudioEngine::AudioEngineThreadPool::*&)(), std::__1::tuple<ax::AudioEngine::AudioEngineThreadPool*>&, std::__1::__tuple_indices<0ul>, std::__1::tuple<>&&) bind.h:263 (cpp-tests:arm64+0x101eada24)
#26 std::__1::__bind_return<void (ax::AudioEngine::AudioEngineThreadPool::*)(), std::__1::tuple<ax::AudioEngine::AudioEngineThreadPool*>, std::__1::tuple<>, __is_valid_bind_return<void (ax::AudioEngine::AudioEngineThreadPool::*)(), std::__1::tuple<ax::AudioEngine::AudioEngineThreadPool*>, std::__1::tuple<>>::value>::type std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>::operator()[abi:v160006]<>() bind.h:295 (cpp-tests:arm64+0x101ead99c)
#27 decltype(std::declval<std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>>()()) std::__1::__invoke[abi:v160006]<std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>>(std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>&&) invoke.h:394 (cpp-tests:arm64+0x101ead8f0)
#28 void std::__1::__thread_execute[abi:v160006]<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>>&, std::__1::__tuple_indices<>) thread:288 (cpp-tests:arm64+0x101ead89c)
#29 void* std::__1::__thread_proxy[abi:v160006]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>>>(void*) thread:299 (cpp-tests:arm64+0x101ead330)

Thread T18 (tid=2140243, running) created by main thread at:

0 pthread_create :264457860 (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x3062c)

#1 std::__1::__libcpp_thread_create[abi:v160006](_opaque_pthread_t**, void* (*)(void*), void*) __threading_support:378 (cpp-tests:arm64+0x100418f88)
#2 std::__1::thread::thread<ax::AsyncTaskPool::ThreadTasks::ThreadTasks()::'lambda'(), void>(ax::AsyncTaskPool::ThreadTasks::ThreadTasks()::'lambda'()&&) thread:315 (cpp-tests:arm64+0x101ee836c)
#3 std::__1::thread::thread<ax::AsyncTaskPool::ThreadTasks::ThreadTasks()::'lambda'(), void>(ax::AsyncTaskPool::ThreadTasks::ThreadTasks()::'lambda'()&&) thread:307 (cpp-tests:arm64+0x101ee7d38)
#4 ax::AsyncTaskPool::ThreadTasks::ThreadTasks() AsyncTaskPool.h:120 (cpp-tests:arm64+0x101ee7c2c)
#5 ax::AsyncTaskPool::ThreadTasks::ThreadTasks() AsyncTaskPool.h:119 (cpp-tests:arm64+0x101ee7a9c)
#6 ax::AsyncTaskPool::AsyncTaskPool() AsyncTaskPool.cpp:48 (cpp-tests:arm64+0x101ee79bc)
#7 ax::AsyncTaskPool::AsyncTaskPool() AsyncTaskPool.cpp:48 (cpp-tests:arm64+0x101ee7874)
#8 ax::AsyncTaskPool::getInstance() AsyncTaskPool.cpp:37 (cpp-tests:arm64+0x101ee7794)
#9 void ax::FileUtils::performOperationOffthread<ax::FileUtils::isFileExist(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>) const::$_6, std::__1::function<void (bool)>>(ax::FileUtils::isFileExist(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>) const::$_6&&, std::__1::function<void (bool)>&&) FileUtils.h:902 (cpp-tests:arm64+0x10226e054)
#10 ax::FileUtils::isFileExist(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>) const FileUtils.cpp:919 (cpp-tests:arm64+0x10226df64)
#11 TestIsFileExistAsync::onEnter() FileUtilsTest.cpp:916 (cpp-tests:arm64+0x1004cb898)
#12 ax::Director::setNextScene() Director.cpp:1158 (cpp-tests:arm64+0x101f53170)
#13 ax::Director::drawScene() Director.cpp:302 (cpp-tests:arm64+0x101f528bc)
#14 ax::Director::mainLoop() Director.cpp:1547 (cpp-tests:arm64+0x101f59da0)
#15 ax::Application::run() Application-mac.mm:76 (cpp-tests:arm64+0x10236560c)
#16 main main.cpp:32 (cpp-tests:arm64+0x1019a6ce4)

SUMMARY: ThreadSanitizer: data race vector:552 in std::1::vector<std::1::function<void ()>, std::1::allocator<std::1::function<void ()>>>::empty[abi:v160006]() const

crazyhappygame commented 8 months ago

Callstack below from MacOs

    #1 ax::Scheduler::update(float) Scheduler.cpp:855 (cpp-tests:arm64+0x102014d94)
    #2 ax::Director::drawScene() Director.cpp:289 (cpp-tests:arm64+0x101f527e8)
    #3 ax::Director::mainLoop() Director.cpp:1547 (cpp-tests:arm64+0x101f59da0)
    #4 ax::Application::run() Application-mac.mm:76 (cpp-tests:arm64+0x10236560c)
    #5 main main.cpp:32 (cpp-tests:arm64+0x1019a6ce4)

I see very often in "Crash details" in Google Play Console. This is the most common crash for my apps

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 16775 >>> com.xxxxx.yyyyy <<<

backtrace:
  #00  pc 0x00000000016aa478  /data/app/~~pM-utHCvJN9laQWVHL2M6A==/com.xxxxx.yyyyy-qf0Rh3-GgoDr-g8jEyeD0w==/lib/arm64/libyyyyy.so (BuildId: b12c7cd37a51bc39a8ef25f3306b2b2ec0e02752)
  #01  pc 0x0000000000ad5730  /data/app/~~pM-utHCvJN9laQWVHL2M6A==/com.xxxxx.yyyyy-qf0Rh3-GgoDr-g8jEyeD0w==/lib/arm64/libyyyyy.so (BuildId: b12c7cd37a51bc39a8ef25f3306b2b2ec0e02752)
  #02  pc 0x00000000009617d4  /data/app/~~pM-utHCvJN9laQWVHL2M6A==/com.xxxxx.yyyyy-qf0Rh3-GgoDr-g8jEyeD0w==/lib/arm64/libyyyyy.so (ax::Sequence::update(float)+336) (BuildId: b12c7cd37a51bc39a8ef25f3306b2b2ec0e02752)
  #03  pc 0x0000000000960e40  /data/app/~~pM-utHCvJN9laQWVHL2M6A==/com.xxxxx.yyyyy-qf0Rh3-GgoDr-g8jEyeD0w==/lib/arm64/libyyyyy.so (ax::ActionInterval::step(float)+88) (BuildId: b12c7cd37a51bc39a8ef25f3306b2b2ec0e02752)
  #04  pc 0x00000000009ee100  /data/app/~~pM-utHCvJN9laQWVHL2M6A==/com.xxxxx.yyyyy-qf0Rh3-GgoDr-g8jEyeD0w==/lib/arm64/libyyyyy.so (ax::ActionManager::update(float)+220) (BuildId: b12c7cd37a51bc39a8ef25f3306b2b2ec0e02752)
  #05  pc 0x0000000000a38124  /data/app/~~pM-utHCvJN9laQWVHL2M6A==/com.xxxxx.yyyyy-qf0Rh3-GgoDr-g8jEyeD0w==/lib/arm64/libyyyyy.so (ax::Scheduler::update(float)+156) (BuildId: b12c7cd37a51bc39a8ef25f3306b2b2ec0e02752)
  #06  pc 0x00000000009e989c  /data/app/~~pM-utHCvJN9laQWVHL2M6A==/com.xxxxx.yyyyy-qf0Rh3-GgoDr-g8jEyeD0w==/lib/arm64/libyyyyy.so (ax::Director::drawScene()+96) (BuildId: b12c7cd37a51bc39a8ef25f3306b2b2ec0e02752)
  #07  pc 0x00000000009ebdec  /data/app/~~pM-utHCvJN9laQWVHL2M6A==/com.xxxxx.yyyyy-qf0Rh3-GgoDr-g8jEyeD0w==/lib/arm64/libyyyyy.so (ax::Director::mainLoop()+124) (BuildId: b12c7cd37a51bc39a8ef25f3306b2b2ec0e02752)
  #08  pc 0x000000000005f550  /data/app/~~pM-utHCvJN9laQWVHL2M6A==/com.xxxxx.yyyyy-qf0Rh3-GgoDr-g8jEyeD0w==/oat/arm64/base.odex.Cjn6Pc.tmp
crazyhappygame commented 8 months ago

Another example

WARNING: ThreadSanitizer: data race (pid=8716)
  Write of size 4 at 0x00011480ac30 by thread T38 (mutexes: write M0):
    #0 ax::AudioCache::readDataTask(unsigned int) AudioCache.cpp:128 (cpp-tests:arm64+0x101e91bc4)
    #1 ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1::operator()() const AudioEngineImpl.cpp:516 (cpp-tests:arm64+0x101ed9e68)
    #2 decltype(std::declval<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1&>()()) std::__1::__invoke[abi:v160006]<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1&>(ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1&) invoke.h:394 (cpp-tests:arm64+0x101ed9d78)
    #3 void std::__1::__invoke_void_return_wrapper<void, true>::__call<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1&>(ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1&) invoke.h:487 (cpp-tests:arm64+0x101ed9cdc)
    #4 std::__1::__function::__alloc_func<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1, std::__1::allocator<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1>, void ()>::operator()[abi:v160006]() function.h:185 (cpp-tests:arm64+0x101ed9c88)
    #5 std::__1::__function::__func<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1, std::__1::allocator<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1>, void ()>::operator()() function.h:356 (cpp-tests:arm64+0x101ed7b80)
    #6 std::__1::__function::__value_func<void ()>::operator()[abi:v160006]() const function.h:510 (cpp-tests:arm64+0x1019d556c)
    #7 std::__1::function<void ()>::operator()() const function.h:1156 (cpp-tests:arm64+0x1019d3674)
    #8 ax::AudioEngine::AudioEngineThreadPool::threadFunc() AudioEngine.cpp:126 (cpp-tests:arm64+0x101ea971c)
    #9 decltype(*std::declval<ax::AudioEngine::AudioEngineThreadPool*&>().*std::declval<void (ax::AudioEngine::AudioEngineThreadPool::*&)()>()()) std::__1::__invoke[abi:v160006]<void (ax::AudioEngine::AudioEngineThreadPool::*&)(), ax::AudioEngine::AudioEngineThreadPool*&, void>(void (ax::AudioEngine::AudioEngineThreadPool::*&)(), ax::AudioEngine::AudioEngineThreadPool*&) invoke.h:359 (cpp-tests:arm64+0x101eadb04)
    #10 std::__1::__bind_return<void (ax::AudioEngine::AudioEngineThreadPool::*)(), std::__1::tuple<ax::AudioEngine::AudioEngineThreadPool*>, std::__1::tuple<>, __is_valid_bind_return<void (ax::AudioEngine::AudioEngineThreadPool::*)(), std::__1::tuple<ax::AudioEngine::AudioEngineThreadPool*>, std::__1::tuple<>>::value>::type std::__1::__apply_functor[abi:v160006]<void (ax::AudioEngine::AudioEngineThreadPool::*)(), std::__1::tuple<ax::AudioEngine::AudioEngineThreadPool*>, 0ul, std::__1::tuple<>>(void (ax::AudioEngine::AudioEngineThreadPool::*&)(), std::__1::tuple<ax::AudioEngine::AudioEngineThreadPool*>&, std::__1::__tuple_indices<0ul>, std::__1::tuple<>&&) bind.h:263 (cpp-tests:arm64+0x101eada24)
    #11 std::__1::__bind_return<void (ax::AudioEngine::AudioEngineThreadPool::*)(), std::__1::tuple<ax::AudioEngine::AudioEngineThreadPool*>, std::__1::tuple<>, __is_valid_bind_return<void (ax::AudioEngine::AudioEngineThreadPool::*)(), std::__1::tuple<ax::AudioEngine::AudioEngineThreadPool*>, std::__1::tuple<>>::value>::type std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>::operator()[abi:v160006]<>() bind.h:295 (cpp-tests:arm64+0x101ead99c)
    #12 decltype(std::declval<std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>>()()) std::__1::__invoke[abi:v160006]<std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>>(std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>&&) invoke.h:394 (cpp-tests:arm64+0x101ead8f0)
    #13 void std::__1::__thread_execute[abi:v160006]<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>>&, std::__1::__tuple_indices<>) thread:288 (cpp-tests:arm64+0x101ead89c)
    #14 void* std::__1::__thread_proxy[abi:v160006]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>>>(void*) thread:299 (cpp-tests:arm64+0x101ead330)

  Previous read of size 4 at 0x00011480ac30 by main thread (mutexes: write M1):
    #0 ax::AudioCache::addPlayCallback(std::__1::function<void ()> const&) AudioCache.cpp:346 (cpp-tests:arm64+0x101e9337c)
    #1 ax::AudioEngineImpl::play2d(std::__1::basic_string_view<char, std::__1::char_traits<char>>, bool, float, float) AudioEngineImpl.cpp:571 (cpp-tests:arm64+0x101ec24c4)
    #2 ax::AudioEngine::play2d(std::__1::basic_string_view<char, std::__1::char_traits<char>>, ax::AudioPlayerSettings const&, ax::AudioProfile const*) AudioEngine.cpp:252 (cpp-tests:arm64+0x101ea2d24)
    #3 ax::AudioEngine::play2d(std::__1::basic_string_view<char, std::__1::char_traits<char>>, bool, float, ax::AudioProfile const*) AudioEngine.cpp:185 (cpp-tests:arm64+0x101ea2860)
    #4 AudioWavTest::onEnter() NewAudioEngineTest.cpp:518 (cpp-tests:arm64+0x100967d1c)
    #5 ax::Director::setNextScene() Director.cpp:1158 (cpp-tests:arm64+0x101f53170)
    #6 ax::Director::drawScene() Director.cpp:302 (cpp-tests:arm64+0x101f528bc)
    #7 ax::Director::mainLoop() Director.cpp:1547 (cpp-tests:arm64+0x101f59da0)
    #8 ax::Application::run() Application-mac.mm:76 (cpp-tests:arm64+0x10236560c)
    #9 main main.cpp:32 (cpp-tests:arm64+0x1019a6ce4)

  Location is heap block of size 296 at 0x00011480ab40 allocated by main thread:
    #0 operator new(unsigned long) <null>:264457860 (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x84420)
    #1 ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>) AudioEngineImpl.cpp:504 (cpp-tests:arm64+0x101ec199c)
    #2 ax::AudioEngineImpl::play2d(std::__1::basic_string_view<char, std::__1::char_traits<char>>, bool, float, float) AudioEngineImpl.cpp:559 (cpp-tests:arm64+0x101ec230c)
    #3 ax::AudioEngine::play2d(std::__1::basic_string_view<char, std::__1::char_traits<char>>, ax::AudioPlayerSettings const&, ax::AudioProfile const*) AudioEngine.cpp:252 (cpp-tests:arm64+0x101ea2d24)
    #4 ax::AudioEngine::play2d(std::__1::basic_string_view<char, std::__1::char_traits<char>>, bool, float, ax::AudioProfile const*) AudioEngine.cpp:185 (cpp-tests:arm64+0x101ea2860)
    #5 AudioWavTest::onEnter() NewAudioEngineTest.cpp:518 (cpp-tests:arm64+0x100967d1c)
    #6 ax::Director::setNextScene() Director.cpp:1158 (cpp-tests:arm64+0x101f53170)
    #7 ax::Director::drawScene() Director.cpp:302 (cpp-tests:arm64+0x101f528bc)
    #8 ax::Director::mainLoop() Director.cpp:1547 (cpp-tests:arm64+0x101f59da0)
    #9 ax::Application::run() Application-mac.mm:76 (cpp-tests:arm64+0x10236560c)
    #10 main main.cpp:32 (cpp-tests:arm64+0x1019a6ce4)

  Mutex M0 (0x00011480abf0) created at:
    #0 pthread_mutex_lock <null>:264457860 (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x3cf8c)
    #1 std::__1::mutex::lock() <null>:264457860 (libc++.1.dylib:arm64e+0x16710)
    #2 ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1::operator()() const AudioEngineImpl.cpp:516 (cpp-tests:arm64+0x101ed9e68)
    #3 decltype(std::declval<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1&>()()) std::__1::__invoke[abi:v160006]<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1&>(ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1&) invoke.h:394 (cpp-tests:arm64+0x101ed9d78)
    #4 void std::__1::__invoke_void_return_wrapper<void, true>::__call<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1&>(ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1&) invoke.h:487 (cpp-tests:arm64+0x101ed9cdc)
    #5 std::__1::__function::__alloc_func<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1, std::__1::allocator<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1>, void ()>::operator()[abi:v160006]() function.h:185 (cpp-tests:arm64+0x101ed9c88)
    #6 std::__1::__function::__func<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1, std::__1::allocator<ax::AudioEngineImpl::preload(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::function<void (bool)>)::$_1>, void ()>::operator()() function.h:356 (cpp-tests:arm64+0x101ed7b80)
    #7 std::__1::__function::__value_func<void ()>::operator()[abi:v160006]() const function.h:510 (cpp-tests:arm64+0x1019d556c)
    #8 std::__1::function<void ()>::operator()() const function.h:1156 (cpp-tests:arm64+0x1019d3674)
    #9 ax::AudioEngine::AudioEngineThreadPool::threadFunc() AudioEngine.cpp:126 (cpp-tests:arm64+0x101ea971c)
    #10 decltype(*std::declval<ax::AudioEngine::AudioEngineThreadPool*&>().*std::declval<void (ax::AudioEngine::AudioEngineThreadPool::*&)()>()()) std::__1::__invoke[abi:v160006]<void (ax::AudioEngine::AudioEngineThreadPool::*&)(), ax::AudioEngine::AudioEngineThreadPool*&, void>(void (ax::AudioEngine::AudioEngineThreadPool::*&)(), ax::AudioEngine::AudioEngineThreadPool*&) invoke.h:359 (cpp-tests:arm64+0x101eadb04)
    #11 std::__1::__bind_return<void (ax::AudioEngine::AudioEngineThreadPool::*)(), std::__1::tuple<ax::AudioEngine::AudioEngineThreadPool*>, std::__1::tuple<>, __is_valid_bind_return<void (ax::AudioEngine::AudioEngineThreadPool::*)(), std::__1::tuple<ax::AudioEngine::AudioEngineThreadPool*>, std::__1::tuple<>>::value>::type std::__1::__apply_functor[abi:v160006]<void (ax::AudioEngine::AudioEngineThreadPool::*)(), std::__1::tuple<ax::AudioEngine::AudioEngineThreadPool*>, 0ul, std::__1::tuple<>>(void (ax::AudioEngine::AudioEngineThreadPool::*&)(), std::__1::tuple<ax::AudioEngine::AudioEngineThreadPool*>&, std::__1::__tuple_indices<0ul>, std::__1::tuple<>&&) bind.h:263 (cpp-tests:arm64+0x101eada24)
    #12 std::__1::__bind_return<void (ax::AudioEngine::AudioEngineThreadPool::*)(), std::__1::tuple<ax::AudioEngine::AudioEngineThreadPool*>, std::__1::tuple<>, __is_valid_bind_return<void (ax::AudioEngine::AudioEngineThreadPool::*)(), std::__1::tuple<ax::AudioEngine::AudioEngineThreadPool*>, std::__1::tuple<>>::value>::type std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>::operator()[abi:v160006]<>() bind.h:295 (cpp-tests:arm64+0x101ead99c)
    #13 decltype(std::declval<std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>>()()) std::__1::__invoke[abi:v160006]<std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>>(std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>&&) invoke.h:394 (cpp-tests:arm64+0x101ead8f0)
    #14 void std::__1::__thread_execute[abi:v160006]<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>>&, std::__1::__tuple_indices<>) thread:288 (cpp-tests:arm64+0x101ead89c)
    #15 void* std::__1::__thread_proxy[abi:v160006]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>>>(void*) thread:299 (cpp-tests:arm64+0x101ead330)

  Mutex M1 (0x00011480ab80) created at:
    #0 pthread_mutex_lock <null>:264457860 (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x3cf8c)
    #1 std::__1::mutex::lock() <null>:264457860 (libc++.1.dylib:arm64e+0x16710)
    #2 std::__1::lock_guard<std::__1::mutex>::lock_guard[abi:v160006](std::__1::mutex&) __mutex_base:94 (cpp-tests:arm64+0x101e934b8)
    #3 ax::AudioCache::addPlayCallback(std::__1::function<void ()> const&) AudioCache.cpp:345 (cpp-tests:arm64+0x101e9336c)
    #4 ax::AudioEngineImpl::play2d(std::__1::basic_string_view<char, std::__1::char_traits<char>>, bool, float, float) AudioEngineImpl.cpp:571 (cpp-tests:arm64+0x101ec24c4)
    #5 ax::AudioEngine::play2d(std::__1::basic_string_view<char, std::__1::char_traits<char>>, ax::AudioPlayerSettings const&, ax::AudioProfile const*) AudioEngine.cpp:252 (cpp-tests:arm64+0x101ea2d24)
    #6 ax::AudioEngine::play2d(std::__1::basic_string_view<char, std::__1::char_traits<char>>, bool, float, ax::AudioProfile const*) AudioEngine.cpp:185 (cpp-tests:arm64+0x101ea2860)
    #7 AudioWavTest::onEnter() NewAudioEngineTest.cpp:518 (cpp-tests:arm64+0x100967d1c)
    #8 ax::Director::setNextScene() Director.cpp:1158 (cpp-tests:arm64+0x101f53170)
    #9 ax::Director::drawScene() Director.cpp:302 (cpp-tests:arm64+0x101f528bc)
    #10 ax::Director::mainLoop() Director.cpp:1547 (cpp-tests:arm64+0x101f59da0)
    #11 ax::Application::run() Application-mac.mm:76 (cpp-tests:arm64+0x10236560c)
    #12 main main.cpp:32 (cpp-tests:arm64+0x1019a6ce4)

  Thread T38 (tid=2164248, running) created by main thread at:
    #0 pthread_create <null>:264457860 (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x3062c)
    #1 std::__1::__libcpp_thread_create[abi:v160006](_opaque_pthread_t**, void* (*)(void*), void*) __threading_support:378 (cpp-tests:arm64+0x100418f88)
    #2 std::__1::thread::thread<std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>, void>(std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>&&) thread:315 (cpp-tests:arm64+0x101ead114)
    #3 std::__1::thread::thread<std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>, void>(std::__1::__bind<void (ax::AudioEngine::AudioEngineThreadPool::*)(), ax::AudioEngine::AudioEngineThreadPool*>&&) thread:307 (cpp-tests:arm64+0x101ea97fc)
    #4 ax::AudioEngine::AudioEngineThreadPool::AudioEngineThreadPool(int) AudioEngine.cpp:77 (cpp-tests:arm64+0x101ea9354)
    #5 ax::AudioEngine::AudioEngineThreadPool::AudioEngineThreadPool(int) AudioEngine.cpp:74 (cpp-tests:arm64+0x101ea2798)
    #6 ax::AudioEngine::lazyInit() AudioEngine.cpp:176 (cpp-tests:arm64+0x101ea26a8)
    #7 ax::AudioEngine::play2d(std::__1::basic_string_view<char, std::__1::char_traits<char>>, ax::AudioPlayerSettings const&, ax::AudioProfile const*) AudioEngine.cpp:199 (cpp-tests:arm64+0x101ea290c)
    #8 ax::AudioEngine::play2d(std::__1::basic_string_view<char, std::__1::char_traits<char>>, bool, float, ax::AudioProfile const*) AudioEngine.cpp:185 (cpp-tests:arm64+0x101ea2860)
    #9 AudioControlTest::init()::$_20::operator()((anonymous namespace)::TextButton*) const NewAudioEngineTest.cpp:246 (cpp-tests:arm64+0x1009b4e84)
    #10 decltype(std::declval<AudioControlTest::init()::$_20&>()(std::declval<(anonymous namespace)::TextButton*>())) std::__1::__invoke[abi:v160006]<AudioControlTest::init()::$_20&, (anonymous namespace)::TextButton*>(AudioControlTest::init()::$_20&, (anonymous namespace)::TextButton*&&) invoke.h:394 (cpp-tests:arm64+0x1009b4d74)
    #11 void std::__1::__invoke_void_return_wrapper<void, true>::__call<AudioControlTest::init()::$_20&, (anonymous namespace)::TextButton*>(AudioControlTest::init()::$_20&, (anonymous namespace)::TextButton*&&) invoke.h:487 (cpp-tests:arm64+0x1009b4cb0)
    #12 std::__1::__function::__alloc_func<AudioControlTest::init()::$_20, std::__1::allocator<AudioControlTest::init()::$_20>, void ((anonymous namespace)::TextButton*)>::operator()[abi:v160006]((anonymous namespace)::TextButton*&&) function.h:185 (cpp-tests:arm64+0x1009b4c4c)
    #13 std::__1::__function::__func<AudioControlTest::init()::$_20, std::__1::allocator<AudioControlTest::init()::$_20>, void ((anonymous namespace)::TextButton*)>::operator()((anonymous namespace)::TextButton*&&) function.h:356 (cpp-tests:arm64+0x1009b2b34)
    #14 std::__1::__function::__value_func<void ((anonymous namespace)::TextButton*)>::operator()[abi:v160006]((anonymous namespace)::TextButton*&&) const function.h:510 (cpp-tests:arm64+0x100971a88)
    #15 std::__1::function<void ((anonymous namespace)::TextButton*)>::operator()((anonymous namespace)::TextButton*) const function.h:1156 (cpp-tests:arm64+0x100971960)
    #16 (anonymous namespace)::TextButton::onTouchEnded(ax::Touch*, ax::Event*) NewAudioEngineTest.cpp:140 (cpp-tests:arm64+0x10096d6b0)
    #17 decltype(*std::declval<(anonymous namespace)::TextButton*&>().*std::declval<void ((anonymous namespace)::TextButton::*&)(ax::Touch*, ax::Event*)>()(std::declval<ax::Touch*>(), std::declval<ax::Event*>())) std::__1::__invoke[abi:v160006]<void ((anonymous namespace)::TextButton::*&)(ax::Touch*, ax::Event*), (anonymous namespace)::TextButton*&, ax::Touch*, ax::Event*, void>(void ((anonymous namespace)::TextButton::*&)(ax::Touch*, ax::Event*), (anonymous namespace)::TextButton*&, ax::Touch*&&, ax::Event*&&) invoke.h:359 (cpp-tests:arm64+0x100974bcc)
    #18 std::__1::__bind_return<void ((anonymous namespace)::TextButton::*)(ax::Touch*, ax::Event*), std::__1::tuple<(anonymous namespace)::TextButton*, std::__1::placeholders::__ph<1>, std::__1::placeholders::__ph<2>>, std::__1::tuple<ax::Touch*&&, ax::Event*&&>, __is_valid_bind_return<void ((anonymous namespace)::TextButton::*)(ax::Touch*, ax::Event*), std::__1::tuple<(anonymous namespace)::TextButton*, std::__1::placeholders::__ph<1>, std::__1::placeholders::__ph<2>>, std::__1::tuple<ax::Touch*&&, ax::Event*&&>>::value>::type std::__1::__apply_functor[abi:v160006]<void ((anonymous namespace)::TextButton::*)(ax::Touch*, ax::Event*), std::__1::tuple<(anonymous namespace)::TextButton*, std::__1::placeholders::__ph<1>, std::__1::placeholders::__ph<2>>, 0ul, 1ul, 2ul, std::__1::tuple<ax::Touch*&&, ax::Event*&&>>(void ((anonymous namespace)::TextButton::*&)(ax::Touch*, ax::Event*), std::__1::tuple<(anonymous namespace)::TextButton*, std::__1::placeholders::__ph<1>, std::__1::placeholders::__ph<2>>&, std::__1::__tuple_indices<0ul, 1ul, 2ul>, std::__1::tuple<ax::Touch*&&, ax::Event*&&>&&) bind.h:263 (cpp-tests:arm64+0x100974a9c)
    #19 std::__1::__bind_return<void ((anonymous namespace)::TextButton::*)(ax::Touch*, ax::Event*), std::__1::tuple<(anonymous namespace)::TextButton*, std::__1::placeholders::__ph<1>, std::__1::placeholders::__ph<2>>, std::__1::tuple<ax::Touch*&&, ax::Event*&&>, __is_valid_bind_return<void ((anonymous namespace)::TextButton::*)(ax::Touch*, ax::Event*), std::__1::tuple<(anonymous namespace)::TextButton*, std::__1::placeholders::__ph<1>, std::__1::placeholders::__ph<2>>, std::__1::tuple<ax::Touch*&&, ax::Event*&&>>::value>::type std::__1::__bind<void ((anonymous namespace)::TextButton::*)(ax::Touch*, ax::Event*), (anonymous namespace)::TextButton*, std::__1::placeholders::__ph<1> const&, std::__1::placeholders::__ph<2> const&>::operator()[abi:v160006]<ax::Touch*, ax::Event*>(ax::Touch*&&, ax::Event*&&) bind.h:295 (cpp-tests:arm64+0x1009749e4)
    #20 decltype(std::declval<std::__1::__bind<void ((anonymous namespace)::TextButton::*)(ax::Touch*, ax::Event*), (anonymous namespace)::TextButton*, std::__1::placeholders::__ph<1> const&, std::__1::placeholders::__ph<2> const&>&>()(std::declval<ax::Touch*>(), std::declval<ax::Event*>())) std::__1::__invoke[abi:v160006]<std::__1::__bind<void ((anonymous namespace)::TextButton::*)(ax::Touch*, ax::Event*), (anonymous namespace)::TextButton*, std::__1::placeholders::__ph<1> const&, std::__1::placeholders::__ph<2> const&>&, ax::Touch*, ax::Event*>(std::__1::__bind<void ((anonymous namespace)::TextButton::*)(ax::Touch*, ax::Event*), (anonymous namespace)::TextButton*, std::__1::placeholders::__ph<1> const&, std::__1::placeholders::__ph<2> const&>&, ax::Touch*&&, ax::Event*&&) invoke.h:394 (cpp-tests:arm64+0x100974950)
    #21 void std::__1::__invoke_void_return_wrapper<void, true>::__call<std::__1::__bind<void ((anonymous namespace)::TextButton::*)(ax::Touch*, ax::Event*), (anonymous namespace)::TextButton*, std::__1::placeholders::__ph<1> const&, std::__1::placeholders::__ph<2> const&>&, ax::Touch*, ax::Event*>(std::__1::__bind<void ((anonymous namespace)::TextButton::*)(ax::Touch*, ax::Event*), (anonymous namespace)::TextButton*, std::__1::placeholders::__ph<1> const&, std::__1::placeholders::__ph<2> const&>&, ax::Touch*&&, ax::Event*&&) invoke.h:487 (cpp-tests:arm64+0x100974894)
    #22 std::__1::__function::__alloc_func<std::__1::__bind<void ((anonymous namespace)::TextButton::*)(ax::Touch*, ax::Event*), (anonymous namespace)::TextButton*, std::__1::placeholders::__ph<1> const&, std::__1::placeholders::__ph<2> const&>, std::__1::allocator<std::__1::__bind<void ((anonymous namespace)::TextButton::*)(ax::Touch*, ax::Event*), (anonymous namespace)::TextButton*, std::__1::placeholders::__ph<1> const&, std::__1::placeholders::__ph<2> const&>>, void (ax::Touch*, ax::Event*)>::operator()[abi:v160006](ax::Touch*&&, ax::Event*&&) function.h:185 (cpp-tests:arm64+0x100974820)
    #23 std::__1::__function::__func<std::__1::__bind<void ((anonymous namespace)::TextButton::*)(ax::Touch*, ax::Event*), (anonymous namespace)::TextButton*, std::__1::placeholders::__ph<1> const&, std::__1::placeholders::__ph<2> const&>, std::__1::allocator<std::__1::__bind<void ((anonymous namespace)::TextButton::*)(ax::Touch*, ax::Event*), (anonymous namespace)::TextButton*, std::__1::placeholders::__ph<1> const&, std::__1::placeholders::__ph<2> const&>>, void (ax::Touch*, ax::Event*)>::operator()(ax::Touch*&&, ax::Event*&&) function.h:356 (cpp-tests:arm64+0x100972ab4)
    #24 std::__1::__function::__value_func<void (ax::Touch*, ax::Event*)>::operator()[abi:v160006](ax::Touch*&&, ax::Event*&&) const function.h:510 (cpp-tests:arm64+0x101fb12b4)
    #25 std::__1::function<void (ax::Touch*, ax::Event*)>::operator()(ax::Touch*, ax::Event*) const function.h:1156 (cpp-tests:arm64+0x101faee7c)
    #26 ax::EventDispatcher::dispatchTouchEvent(ax::EventTouch*)::$_3::operator()(ax::EventListener*) const EventDispatcher.cpp:1085 (cpp-tests:arm64+0x101fae460)
    #27 decltype(std::declval<ax::EventDispatcher::dispatchTouchEvent(ax::EventTouch*)::$_3&>()(std::declval<ax::EventListener*>())) std::__1::__invoke[abi:v160006]<ax::EventDispatcher::dispatchTouchEvent(ax::EventTouch*)::$_3&, ax::EventListener*>(ax::EventDispatcher::dispatchTouchEvent(ax::EventTouch*)::$_3&, ax::EventListener*&&) invoke.h:394 (cpp-tests:arm64+0x101fae040)
    #28 bool std::__1::__invoke_void_return_wrapper<bool, false>::__call<ax::EventDispatcher::dispatchTouchEvent(ax::EventTouch*)::$_3&, ax::EventListener*>(ax::EventDispatcher::dispatchTouchEvent(ax::EventTouch*)::$_3&, ax::EventListener*&&) invoke.h:478 (cpp-tests:arm64+0x101fadf70)
    #29 std::__1::__function::__alloc_func<ax::EventDispatcher::dispatchTouchEvent(ax::EventTouch*)::$_3, std::__1::allocator<ax::EventDispatcher::dispatchTouchEvent(ax::EventTouch*)::$_3>, bool (ax::EventListener*)>::operator()[abi:v160006](ax::EventListener*&&) function.h:185 (cpp-tests:arm64+0x101fadf00)
    #30 std::__1::__function::__func<ax::EventDispatcher::dispatchTouchEvent(ax::EventTouch*)::$_3, std::__1::allocator<ax::EventDispatcher::dispatchTouchEvent(ax::EventTouch*)::$_3>, bool (ax::EventListener*)>::operator()(ax::EventListener*&&) function.h:356 (cpp-tests:arm64+0x101fac198)
    #31 std::__1::__function::__value_func<bool (ax::EventListener*)>::operator()[abi:v160006](ax::EventListener*&&) const function.h:510 (cpp-tests:arm64+0x101fa7dcc)
    #32 std::__1::function<bool (ax::EventListener*)>::operator()(ax::EventListener*) const function.h:1156 (cpp-tests:arm64+0x101f79264)
    #33 ax::EventDispatcher::dispatchTouchEventToListeners(ax::EventDispatcher::EventListenerVector*, std::__1::function<bool (ax::EventListener*)> const&) EventDispatcher.cpp:927 (cpp-tests:arm64+0x101f7988c)
    #34 ax::EventDispatcher::dispatchTouchEvent(ax::EventTouch*) EventDispatcher.cpp:1132 (cpp-tests:arm64+0x101f7a5b4)
    #35 ax::EventDispatcher::dispatchEvent(ax::Event*) EventDispatcher.cpp:973 (cpp-tests:arm64+0x101f79dbc)
    #36 ax::GLView::handleTouchesOfEndOrCancel(ax::EventTouch::EventCode, int, long*, float*, float*) GLView.cpp:454 (cpp-tests:arm64+0x1023141d8)
    #37 ax::GLView::handleTouchesEnd(int, long*, float*, float*) GLView.cpp:465 (cpp-tests:arm64+0x10231443c)
    #38 ax::GLViewImpl::onGLFWMouseCallBack(GLFWwindow*, int, int, int) GLViewImpl.cpp:1047 (cpp-tests:arm64+0x10231c760)
    #39 ax::GLFWEventHandler::onGLFWMouseCallBack(GLFWwindow*, int, int, int) GLViewImpl.cpp:100 (cpp-tests:arm64+0x102319c40)
    #40 ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int, int, int) imgui_impl_ax.cpp:406 (cpp-tests:arm64+0x102997820)
    #41 _glfwInputMouseClick input.c:367 (cpp-tests:arm64+0x103926298)
    #42 -[GLFWContentView mouseUp:] cocoa_window.m:419 (cpp-tests:arm64+0x10391391c)
    #43 _routeMouseUpEvent <null>:264457860 (AppKit:arm64e+0xb73830)
    #44 glfwPollEvents window.c:1154 (cpp-tests:arm64+0x103940b20)
    #45 ax::GLViewImpl::pollEvents() GLViewImpl.cpp:678 (cpp-tests:arm64+0x10231a534)
    #46 ax::Director::drawScene() Director.cpp:282 (cpp-tests:arm64+0x101f52760)
    #47 ax::Director::mainLoop() Director.cpp:1547 (cpp-tests:arm64+0x101f59da0)
    #48 ax::Application::run() Application-mac.mm:76 (cpp-tests:arm64+0x10236560c)
    #49 main main.cpp:32 (cpp-tests:arm64+0x1019a6ce4)

SUMMARY: ThreadSanitizer: data race AudioCache.cpp:128 in ax::AudioCache::readDataTask(unsigned int)
crazyhappygame commented 8 months ago

One more after clossing cpp-tests

==================
WARNING: ThreadSanitizer: data race (pid=38905)
  Write of size 1 at 0x000115a03c81 by main thread:
    #0 ax::Console::stop() Console.cpp:551 (cpp-tests:arm64+0x101f028a0)
    #1 ax::Console::~Console() Console.cpp:497 (cpp-tests:arm64+0x101f02718)
    #2 ax::Console::~Console() Console.cpp:496 (cpp-tests:arm64+0x101f02938)
    #3 ax::Console::~Console() Console.cpp:496 (cpp-tests:arm64+0x101f02980)
    #4 ax::Director::~Director() Director.cpp:192 (cpp-tests:arm64+0x101f514dc)
    #5 ax::Director::~Director() Director.cpp:164 (cpp-tests:arm64+0x101f4ff60)
    #6 ax::Director::destroyInstance() Director.cpp:103 (cpp-tests:arm64+0x101f4fef0)
    #7 ax::ApplicationBase::~ApplicationBase() ApplicationBase.cpp:35 (cpp-tests:arm64+0x10226700c)
    #8 ax::Application::~Application() Application-mac.mm:52 (cpp-tests:arm64+0x102364934)
    #9 AppDelegate::~AppDelegate() AppDelegate.cpp:44 (cpp-tests:arm64+0x1001ba720)
    #10 AppDelegate::~AppDelegate() AppDelegate.cpp:40 (cpp-tests:arm64+0x1001ba768)
    #11 main main.cpp:33 (cpp-tests:arm64+0x1019a5cfc)

  Previous read of size 1 at 0x000115a03c81 by thread T6:
    #0 ax::Console::loop() Console.cpp:670 (cpp-tests:arm64+0x101f031c8)
    #1 decltype(*std::declval<ax::Console*&>().*std::declval<void (ax::Console::*&)()>()()) std::__1::__invoke[abi:v160006]<void (ax::Console::*&)(), ax::Console*&, void>(void (ax::Console::*&)(), ax::Console*&) invoke.h:359 (cpp-tests:arm64+0x101f1c6d4)
    #2 std::__1::__bind_return<void (ax::Console::*)(), std::__1::tuple<ax::Console*>, std::__1::tuple<>, __is_valid_bind_return<void (ax::Console::*)(), std::__1::tuple<ax::Console*>, std::__1::tuple<>>::value>::type std::__1::__apply_functor[abi:v160006]<void (ax::Console::*)(), std::__1::tuple<ax::Console*>, 0ul, std::__1::tuple<>>(void (ax::Console::*&)(), std::__1::tuple<ax::Console*>&, std::__1::__tuple_indices<0ul>, std::__1::tuple<>&&) bind.h:263 (cpp-tests:arm64+0x101f1c5f4)
    #3 std::__1::__bind_return<void (ax::Console::*)(), std::__1::tuple<ax::Console*>, std::__1::tuple<>, __is_valid_bind_return<void (ax::Console::*)(), std::__1::tuple<ax::Console*>, std::__1::tuple<>>::value>::type std::__1::__bind<void (ax::Console::*)(), ax::Console*>::operator()[abi:v160006]<>() bind.h:295 (cpp-tests:arm64+0x101f1c56c)
    #4 decltype(std::declval<std::__1::__bind<void (ax::Console::*)(), ax::Console*>>()()) std::__1::__invoke[abi:v160006]<std::__1::__bind<void (ax::Console::*)(), ax::Console*>>(std::__1::__bind<void (ax::Console::*)(), ax::Console*>&&) invoke.h:394 (cpp-tests:arm64+0x101f1c4c0)
    #5 void std::__1::__thread_execute[abi:v160006]<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, std::__1::__bind<void (ax::Console::*)(), ax::Console*>>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, std::__1::__bind<void (ax::Console::*)(), ax::Console*>>&, std::__1::__tuple_indices<>) thread:288 (cpp-tests:arm64+0x101f1c46c)
    #6 void* std::__1::__thread_proxy[abi:v160006]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, std::__1::__bind<void (ax::Console::*)(), ax::Console*>>>(void*) thread:299 (cpp-tests:arm64+0x101f1bf00)

  As if synchronized via sleep:
    #0 usleep <null>:280333956 (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x2f50c)
    #1 <null> <null>:280333956 (CoreAudio:arm64e+0xbfa4)
    #2 ax::AudioEngineImpl::~AudioEngineImpl() AudioEngineImpl.cpp:333 (cpp-tests:arm64+0x101ec08b4)
    #3 ax::AudioEngineImpl::~AudioEngineImpl() AudioEngineImpl.cpp:333 (cpp-tests:arm64+0x101ec08fc)
    #4 ax::AudioEngine::end() AudioEngine.cpp:153 (cpp-tests:arm64+0x101ea1844)
    #5 ax::Director::reset() Director.cpp:1002 (cpp-tests:arm64+0x101f564ac)
    #6 ax::Director::cleanupDirector() Director.cpp:1070 (cpp-tests:arm64+0x101f568cc)
    #7 ax::Director::mainLoop() Director.cpp:1538 (cpp-tests:arm64+0x101f591f0)
    #8 ax::Application::run() Application-mac.mm:95 (cpp-tests:arm64+0x102364bd4)
    #9 main main.cpp:32 (cpp-tests:arm64+0x1019a5ce4)

  Location is heap block of size 344 at 0x000115a03c00 allocated by main thread:
    #0 operator new(unsigned long) <null>:280333956 (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x84420)
    #1 ax::Director::init() Director.cpp:117 (cpp-tests:arm64+0x101f4f704)
    #2 ax::Director::getInstance() Director.cpp:95 (cpp-tests:arm64+0x101f4f5c4)
    #3 ax::Configuration::loadConfigFile(std::__1::basic_string_view<char, std::__1::char_traits<char>>) Configuration.cpp:401 (cpp-tests:arm64+0x101ef4f10)
    #4 AppDelegate::applicationDidFinishLaunching() AppDelegate.cpp:64 (cpp-tests:arm64+0x1001ba8f0)
    #5 ax::Application::run() Application-mac.mm:57 (cpp-tests:arm64+0x102364a14)
    #6 main main.cpp:32 (cpp-tests:arm64+0x1019a5ce4)

  Thread T6 (tid=2352912, running) created by main thread at:
    #0 pthread_create <null>:280333956 (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x3062c)
    #1 std::__1::__libcpp_thread_create[abi:v160006](_opaque_pthread_t**, void* (*)(void*), void*) __threading_support:378 (cpp-tests:arm64+0x100417f88)
    #2 std::__1::thread::thread<std::__1::__bind<void (ax::Console::*)(), ax::Console*>, void>(std::__1::__bind<void (ax::Console::*)(), ax::Console*>&&) thread:315 (cpp-tests:arm64+0x101f1bce4)
    #3 std::__1::thread::thread<std::__1::__bind<void (ax::Console::*)(), ax::Console*>, void>(std::__1::__bind<void (ax::Console::*)(), ax::Console*>&&) thread:307 (cpp-tests:arm64+0x101f03884)
    #4 ax::Console::listenOnFileDescriptor(int) Console.cpp:542 (cpp-tests:arm64+0x101f03070)
    #5 ax::Console::listenOnTCP(int) Console.cpp:530 (cpp-tests:arm64+0x101f02c68)
    #6 AppDelegate::applicationDidFinishLaunching() AppDelegate.cpp:121 (cpp-tests:arm64+0x1001bacd8)
    #7 ax::Application::run() Application-mac.mm:57 (cpp-tests:arm64+0x102364a14)
    #8 main main.cpp:32 (cpp-tests:arm64+0x1019a5ce4)

SUMMARY: ThreadSanitizer: data race Console.cpp:551 in ax::Console::stop()
==================
rh101 commented 8 months ago

Are you sure that the source of these issues isn't the autotest? The auto-test TestController uses threads, and there could be something in there that is causing all of these problems.

halx99 commented 8 months ago

yes, the auto test not consider thread safe, so no significance for thread santizer.

crazyhappygame commented 8 months ago
  1. Please check https://github.com/axmolengine/axmol/issues/1751 . On my Mac pressing “Start auto test” immediately crashes.
  2. Issues above are seen in cpp-test after pressing on particular test. for example NewAudioEngine,play
  3. I see similar ThreadSanitizer issues that I posted for cpp-test in my app
stale[bot] commented 5 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

crazyhappygame commented 5 months ago

issue still exsist on the latest axmol version

halx99 commented 3 months ago

Root cuase is cppt-tests try request GPU resources on subthread, after rewrite the AutoTest controller with coroutine, this issue will be fixed