<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>195161</bug_id>
          
          <creation_ts>2019-02-28 05:58:23 -0800</creation_ts>
          <short_desc>Flaky API Test: TestWTF.WTF_SynchronizedFixedQueue.ProduceOnly</short_desc>
          <delta_ts>2023-05-03 23:22:56 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Tools / Tests</component>
          <version>Other</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=176056</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Aakash Jain">aakash_jain</reporter>
          <assigned_to name="Fujii Hironori">fujii</assigned_to>
          <cc>aakash_jain</cc>
    
    <cc>ap</cc>
    
    <cc>fujii</cc>
    
    <cc>lforschler</cc>
    
    <cc>sabouhallawa</cc>
    
    <cc>webkit-bot-watchers-bugzilla</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1510911</commentid>
    <comment_count>0</comment_count>
    <who name="Aakash Jain">aakash_jain</who>
    <bug_when>2019-02-28 05:58:23 -0800</bug_when>
    <thetext>TestWTF.WTF_SynchronizedFixedQueue.ProduceOnly seems flaky. In https://ews-build.webkit-uat.org/#/builders/19/builds/1307, the test Failed in run-api-tests step. However, in the immediately next retry step (re-run-api-tests), it passed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1533517</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2019-05-06 13:16:21 -0700</bug_when>
    <thetext>&lt;rdar://problem/50510054&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1951518</commentid>
    <comment_count>2</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2023-04-26 22:58:07 -0700</bug_when>
    <thetext>Only WinCairo port is randomly timing out these days.
https://results.webkit.org/?suite=api-tests&amp;test=TestWTF.WTF_SynchronizedFixedQueue.ProduceOnly</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1951519</commentid>
    <comment_count>3</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2023-04-26 22:59:22 -0700</bug_when>
    <thetext>Main thread

&gt; ntdll.dll!00007fff6d970a74()	Unknown
&gt; ntdll.dll!00007fff6d934131()	Unknown
&gt; KernelBase.dll!00007fff6b1030e9()	Unknown
&gt; WTF.dll!WTF::ThreadCondition::timedWait(WTF::Mutex &amp; mutex, WTF::WallTime absoluteTime) Line 386	C++
&gt; WTF.dll!WTF::ParkingLot::parkConditionallyImpl(const void * address, const WTF::ScopedLambda&lt;bool __cdecl(void)&gt; &amp; validation, const WTF::ScopedLambda&lt;void __cdecl(void)&gt; &amp; beforeSleep, const WTF::TimeWithDynamicClockType &amp; timeout) Line 602	C++
&gt; WTF.dll!WTF::ParkingLot::parkConditionally&lt;`WTF::Condition::waitUntilUnchecked&lt;WTF::Lock&gt;&apos;::`7&apos;::&lt;lambda_1&gt;,`WTF::Condition::waitUntilUnchecked&lt;WTF::Lock&gt;&apos;::`7&apos;::&lt;lambda_2&gt;&gt;(const void * address, const WTF::Condition::waitUntilUnchecked::__l7::&lt;lambda_1&gt; &amp; validation, const WTF::Condition::waitUntilUnchecked::__l7::&lt;lambda_2&gt; &amp; beforeSleep, const WTF::TimeWithDynamicClockType &amp; timeout) Line 82	C++
&gt; WTF.dll!WTF::Condition::waitUntilUnchecked&lt;WTF::Lock&gt;(WTF::Lock &amp; lock, const WTF::TimeWithDynamicClockType &amp; timeout) Line 192	C++
&gt; WTF.dll!WTF::Condition::waitUntil(WTF::Lock &amp; lock, const WTF::TimeWithDynamicClockType &amp; timeout) Line 78	C++
&gt; WTF.dll!WTF::Condition::waitUntilUnchecked&lt;WTF::Lock,`WTF::BinarySemaphore::waitUntil&apos;::`2&apos;::&lt;lambda_1&gt;&gt;(WTF::Lock &amp; lock, const WTF::TimeWithDynamicClockType &amp; timeout, const WTF::BinarySemaphore::waitUntil::__l2::&lt;lambda_1&gt; &amp; predicate) Line 213	C++
&gt; WTF.dll!WTF::Condition::waitUntil&lt;`WTF::BinarySemaphore::waitUntil&apos;::`2&apos;::&lt;lambda_1&gt;&gt;(WTF::Lock &amp; lock, const WTF::TimeWithDynamicClockType &amp; timeout, const WTF::BinarySemaphore::waitUntil::__l2::&lt;lambda_1&gt; &amp; predicate) Line 92	C++
&gt; WTF.dll!WTF::BinarySemaphore::waitUntil(const WTF::TimeWithDynamicClockType &amp; absoluteTime) Line 41	C++
&gt; TestWTFLib.dll!WTF::BinarySemaphore::wait() Line 52	C++
&gt; TestWTFLib.dll!TestWebKitAPI::ToUpperConverter&lt;4&gt;::stopProducing() Line 127	C++
&gt; TestWTFLib.dll!TestWebKitAPI::ToUpperConverter&lt;4&gt;::stop() Line 143	C++
&gt; TestWTFLib.dll!TestWebKitAPI::WTF_SynchronizedFixedQueue_ProduceOnly_Test::TestBody() Line 198	C++
&gt; TestWTFLib.dll!testing::internal::HandleSehExceptionsInMethodIfSupported&lt;testing::Test,void&gt;(testing::Test * object, void(testing::Test::*)() method, const char * location) Line 2592	C++
&gt; TestWTFLib.dll!testing::internal::HandleExceptionsInMethodIfSupported&lt;testing::Test,void&gt;(testing::Test * object, void(testing::Test::*)() method, const char * location) Line 2662	C++
&gt; TestWTFLib.dll!testing::Test::Run() Line 2689	C++
&gt; TestWTFLib.dll!testing::TestInfo::Run() Line 2864	C++
&gt; TestWTFLib.dll!testing::TestSuite::Run() Line 3016	C++
&gt; TestWTFLib.dll!testing::internal::UnitTestImpl::RunAllTests() Line 5852	C++
&gt; TestWTFLib.dll!testing::internal::HandleSehExceptionsInMethodIfSupported&lt;testing::internal::UnitTestImpl,bool&gt;(testing::internal::UnitTestImpl * object, bool(testing::internal::UnitTestImpl::*)() method, const char * location) Line 2592	C++
&gt; TestWTFLib.dll!testing::internal::HandleExceptionsInMethodIfSupported&lt;testing::internal::UnitTestImpl,bool&gt;(testing::internal::UnitTestImpl * object, bool(testing::internal::UnitTestImpl::*)() method, const char * location) Line 2662	C++
&gt; TestWTFLib.dll!testing::UnitTest::Run() Line 5434	C++
&gt; TestWTFLib.dll!RUN_ALL_TESTS() Line 2472	C++
&gt; TestWTFLib.dll!TestWebKitAPI::TestsController::run(int argc, char * * argv) Line 89	C++
&gt; TestWTFLib.dll!main(int argc, char * * argv) Line 41	C++
&gt; TestWTFLib.dll!dllLauncherEntryPoint(int argc, char * * argv) Line 49	C++
&gt; TestWTF.exe!main(int argc, const char * * argv) Line 149	C++
&gt; [Inline Frame] TestWTF.exe!invoke_main() Line 78	C++
&gt; TestWTF.exe!__scrt_common_main_seh() Line 288	C++
&gt; kernel32.dll!00007fff6d4b7604()	Unknown
&gt; ntdll.dll!00007fff6d9226a1()	Unknown

Produce thread

&gt; ntdll.dll!00007fff6d970a74()	Unknown
&gt; ntdll.dll!00007fff6d934131()	Unknown
&gt; KernelBase.dll!00007fff6b1030e9()	Unknown
&gt; WTF.dll!WTF::ThreadCondition::timedWait(WTF::Mutex &amp; mutex, WTF::WallTime absoluteTime) Line 386	C++
&gt; WTF.dll!WTF::ParkingLot::parkConditionallyImpl(const void * address, const WTF::ScopedLambda&lt;bool __cdecl(void)&gt; &amp; validation, const WTF::ScopedLambda&lt;void __cdecl(void)&gt; &amp; beforeSleep, const WTF::TimeWithDynamicClockType &amp; timeout) Line 602	C++
&gt; TestWTFLib.dll!WTF::ParkingLot::parkConditionally&lt;`WTF::Condition::waitUntilUnchecked&lt;WTF::Lock&gt;&apos;::`7&apos;::&lt;lambda_1&gt;,`WTF::Condition::waitUntilUnchecked&lt;WTF::Lock&gt;&apos;::`7&apos;::&lt;lambda_2&gt;&gt;(const void * address, const WTF::Condition::waitUntilUnchecked::__l7::&lt;lambda_1&gt; &amp; validation, const WTF::Condition::waitUntilUnchecked::__l7::&lt;lambda_2&gt; &amp; beforeSleep, const WTF::TimeWithDynamicClockType &amp; timeout) Line 82	C++
&gt; TestWTFLib.dll!WTF::Condition::waitUntilUnchecked&lt;WTF::Lock&gt;(WTF::Lock &amp; lock, const WTF::TimeWithDynamicClockType &amp; timeout) Line 192	C++
&gt; TestWTFLib.dll!WTF::Condition::waitUntil(WTF::Lock &amp; lock, const WTF::TimeWithDynamicClockType &amp; timeout) Line 78	C++
&gt; TestWTFLib.dll!WTF::Condition::wait(WTF::Lock &amp; lock) Line 128	C++
&gt; TestWTFLib.dll!WTF::Condition::wait&lt;`WTF::SynchronizedFixedQueue&lt;WTF::CString,4&gt;::enqueue&apos;::`2&apos;::&lt;lambda_1&gt;&gt;(WTF::Lock &amp; lock, const WTF::SynchronizedFixedQueue&lt;WTF::CString,4&gt;::enqueue::__l2::&lt;lambda_1&gt; &amp; predicate) Line 141	C++
&gt; TestWTFLib.dll!WTF::SynchronizedFixedQueue&lt;WTF::CString,4&gt;::enqueue(const WTF::CString &amp; value) Line 82	C++
&gt; TestWTFLib.dll!TestWebKitAPI::ToUpperConverter&lt;4&gt;::startProducing::__l2::&lt;lambda_1&gt;::operator()() Line 86	C++
&gt; TestWTFLib.dll!WTF::Detail::CallableWrapper&lt;`TestWebKitAPI::ToUpperConverter&lt;4&gt;::startProducing&apos;::`2&apos;::&lt;lambda_1&gt;,void&gt;::call() Line 53	C++
&gt; WTF.dll!WTF::Function&lt;void __cdecl(void)&gt;::operator()() Line 83	C++
&gt; WTF.dll!WTF::WorkQueueBase::dispatch::__l2::&lt;lambda_1&gt;::operator()() Line 70	C++
&gt; WTF.dll!WTF::Detail::CallableWrapper&lt;`WTF::WorkQueueBase::dispatch&apos;::`2&apos;::&lt;lambda_1&gt;,void&gt;::call() Line 53	C++
&gt; WTF.dll!WTF::Function&lt;void __cdecl(void)&gt;::operator()() Line 83	C++
&gt; WTF.dll!WTF::RunLoop::performWork() Line 148	C++
&gt; WTF.dll!WTF::RunLoop::wndProc(HWND__ * hWnd, unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 57	C++
&gt; WTF.dll!WTF::RunLoop::RunLoopWndProc(HWND__ * hWnd, unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 39	C++
&gt; user32.dll!00007fff6bc6e858()	Unknown
&gt; user32.dll!00007fff6bc6e299()	Unknown
&gt; WTF.dll!WTF::RunLoop::run() Line 74	C++
&gt; WTF.dll!WTF::RunLoop::create::__l2::&lt;lambda_1&gt;::operator()() Line 115	C++
&gt; WTF.dll!WTF::Detail::CallableWrapper&lt;`WTF::RunLoop::create&apos;::`2&apos;::&lt;lambda_1&gt;,void&gt;::call() Line 53	C++
&gt; WTF.dll!WTF::Function&lt;void __cdecl(void)&gt;::operator()() Line 83	C++
&gt; WTF.dll!WTF::Thread::entryPoint(WTF::Thread::NewThreadContext * newThreadContext) Line 251	C++
&gt; WTF.dll!WTF::wtfThreadEntryPoint(void * data) Line 151	C++
&gt; ucrtbase.dll!00007fff6b761bb2()	Unknown
&gt; kernel32.dll!00007fff6d4b7604()	Unknown
&gt; ntdll.dll!00007fff6d9226a1()	Unknown</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1951521</commentid>
    <comment_count>4</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2023-04-26 23:39:26 -0700</bug_when>
    <thetext>Produce thread is blocked by enqueueing to m_upperQueue becuase it is full.
https://github.com/WebKit/WebKit/blob/7327aab70ea504499e0f1a14c78f55863233afd9/Tools/TestWebKitAPI/Tests/WTF/SynchronizedFixedQueue.cpp#L86

Main thread is blocked by m_produceCloseSemaphore.wait() because Produce thread doesn&apos;t signal.
https://github.com/WebKit/WebKit/blob/7327aab70ea504499e0f1a14c78f55863233afd9/Tools/TestWebKitAPI/Tests/WTF/SynchronizedFixedQueue.cpp#L126

How to fix this bug?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1951523</commentid>
    <comment_count>5</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2023-04-26 23:53:08 -0700</bug_when>
    <thetext>This dead lock can be reliably reproducible by increasing sleep time of enqueueLower.

diff --git a/Tools/TestWebKitAPI/Tests/WTF/SynchronizedFixedQueue.cpp b/Tools/TestWebKitAPI/Tests/WTF/SynchronizedFixedQueue.cpp
index f7a48db75f63..7cebd9fecaff 100644
--- a/Tools/TestWebKitAPI/Tests/WTF/SynchronizedFixedQueue.cpp
+++ b/Tools/TestWebKitAPI/Tests/WTF/SynchronizedFixedQueue.cpp
@@ -191,7 +191,7 @@ TEST(WTF_SynchronizedFixedQueue, ProduceOnly)
         converter.enqueueLower(item);
         ++count;
         
-        std::this_thread::sleep_for(std::chrono::milliseconds(1));
+        std::this_thread::sleep_for(std::chrono::milliseconds(100));
     }
 
     converter.stop();


192736@main (bug#176056) was the previous attempt to fix the dead lock.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1951530</commentid>
    <comment_count>6</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2023-04-27 00:13:16 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/13227</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1952836</commentid>
    <comment_count>7</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-05-03 23:22:53 -0700</bug_when>
    <thetext>Committed 263664@main (5b9202cb4147): &lt;https://commits.webkit.org/263664@main&gt;

Reviewed commits have been landed. Closing PR #13227 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>