TestWebKitAPI.WebKitLegacy.AudioSessionCategoryIOS Is constantly crashing on iOS Debug (iPhone ) and flaky crashing on iOS Release. History: https://results.webkit.org/?suite=api-tests&test=TestWebKitAPI.WebKitLegacy.AudioSessionCategoryIOS https://build.webkit.org/#/builders/267/builds/371/steps/17/logs/stdio Stdio: Crashed TestWebKitAPI.WebKitLegacy.AudioSessionCategoryIOS 2021-11-03 01:55:30.076 TestWebKitAPI[11936:59837708] nil host used in call to allowsSpecificHTTPSCertificateForHost 2021-11-03 01:55:30.076 TestWebKitAPI[11936:59837708] nil host used in call to allowsAnyHTTPSCertificateForHost: 2021-11-03 01:55:32.118 TestWebKitAPI[11936:59837708] Writing analzed variants. 2021-11-03 01:55:32.207 TestWebKitAPI[11936:59837708] *** Warning: <AVPlayerViewController: 0x7fba56816a00> is trying to enter full screen, but is not in its view's window's view controller hierarchy. This results in undefined behavior. 2021-11-03 01:55:32.217 TestWebKitAPI[11936:59837708] nil host used in call to allowsSpecificHTTPSCertificateForHost 2021-11-03 01:55:32.217 TestWebKitAPI[11936:59837708] nil host used in call to allowsAnyHTTPSCertificateForHost: ASSERTION FAILED: !m_impl || !m_shouldEnableAssertions || Thread::mayBeGCThread() || m_impl->wasConstructedOnMainThread() == isMainThread() /Volumes/Data/worker/ios-simulator-15-debug/build/WebKitBuild/Debug-iphonesimulator/usr/local/include/wtf/WeakPtr.h(135) : T *WTF::WeakPtr<WebCore::PlaybackSessionModel>::get() const [T = WebCore::PlaybackSessionModel, Counter = WTF::EmptyCounter] 1 0x117160349 WTFCrash 2 0x162a84f5b WTFCrashWithInfo(int, char const*, char const*, int) 3 0x164cc9457 WTF::WeakPtr<WebCore::PlaybackSessionModel, WTF::EmptyCounter>::get() const 4 0x164cc938d -[WebAVPlayerController delegate] 5 0x16835825b -[WebAVPlayerLayer layoutSublayers] 6 0x10e5192b6 CA::Layer::layout_if_needed(CA::Transaction*) 7 0x10e5244f1 CA::Layer::layout_and_display_if_needed(CA::Transaction*) 8 0x10e4600ca CA::Context::commit_transaction(CA::Transaction*, double, double*) 9 0x10e497c47 CA::Transaction::commit() 10 0x16835c151 WebCore::VideoFullscreenInterfaceAVKit::setInlineRect(WebCore::FloatRect const&, bool) 11 0x16835d635 WebCore::VideoFullscreenInterfaceAVKit::exitFullscreen(WebCore::FloatRect const&) 12 0x16840d256 VideoFullscreenControllerContext::exitFullscreen()::$_45::operator()() const 13 0x16840d0f9 WTF::Detail::CallableWrapper<VideoFullscreenControllerContext::exitFullscreen()::$_45, void>::call() 14 0x11718cc32 WTF::Function<void ()>::operator()() const 15 0x11721a8ce WTF::RunLoop::performWork() 16 0x11721f0fe WTF::RunLoop::performWork(void*) 17 0x11040ee25 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ 18 0x11040ed1d __CFRunLoopDoSource0 19 0x11040e1f2 __CFRunLoopDoSources0 20 0x110408951 __CFRunLoopRun 21 0x110408103 CFRunLoopRunSpecific 22 0x11108341c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] 23 0x109c85e13 TestWebKitAPI::Util::run(bool*) 24 0x109334665 TestWebKitAPI::WebKitLegacy_AudioSessionCategoryIOS_Test::TestBody() 25 0x109e73afb void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) 26 0x109e4b2aa void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) 27 0x109e4b1f3 testing::Test::Run() 28 0x109e4c281 testing::TestInfo::Run() 29 0x109e4d304 testing::TestSuite::Run() 30 0x109e5beff testing::internal::UnitTestImpl::RunAllTests() 31 0x109e77edb bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) Child process terminated with signal 11: Segmentation fault
<rdar://problem/84985299>
According to the history, the test first crashed at r283612.
This is a regression from https://trac.webkit.org/changeset/284743/webkit
Created attachment 443234 [details] Patch
Committed r285231 (243852@main): <https://commits.webkit.org/243852@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 443234 [details].
So WeakPtr<>::get() is not thread-safe, even though WeakPtrImpl<> derives from ThreadSafeRefCounted. I guess that makes sense as we’d have to add locking when accessing the actual object (not just its count) to make it thread-safe.
Reopening to attach new patch.
Created attachment 443328 [details] Patch
Committed r285305 (243884@main): <https://commits.webkit.org/243884@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 443328 [details].