Bug 184583 - REGRESSION(r230627): [GTK][WPE] Possible deadlock when destroying the player in non AC mode
Summary: REGRESSION(r230627): [GTK][WPE] Possible deadlock when destroying the player ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Miguel Gomez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-04-13 04:23 PDT by Miguel Gomez
Modified: 2018-04-13 06:18 PDT (History)
3 users (show)

See Also:


Attachments
Patch (5.58 KB, patch)
2018-04-13 04:45 PDT, Miguel Gomez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Miguel Gomez 2018-04-13 04:23:57 PDT
In my effort to simplify the code in the patch for https://bugs.webkit.org/show_bug.cgi?id=183362 I accidentally added the possibility of a deadlock between the main and gstreamer threads when not in AC mode.

The thing is that when the player destructor is running, there's the possibility that a call to triggerRepaint() is being executed in the gstreamer thread. After r230627 it's possible that cancelRepaint() called from the destructor is executed before triggerRepaint() waits in the m_drawCondition, which means that the gstreamer thread will be locked forever.

The fix here is to put m_destroying inside cancelRepaint() again, and modify it inside the same lock where we notify m_drawCondition. And also check its value in triggerRepaint() inside the m_drawMutex lock. That way, if cancelRepaint() gets executed before triggerRepaint() reaches the lock, triggerRepaint will exit before waiting in the condition, and if cancelRepaint() is executed after triggerRepaint() reaches the lock it will signal the m_drawCondition an release the gstreamer thread.

I'll send a patch in a while and then punish myself writing 500 times "watch out with the race conditions" :(
Comment 1 Miguel Gomez 2018-04-13 04:45:05 PDT
Created attachment 337880 [details]
Patch
Comment 2 WebKit Commit Bot 2018-04-13 06:18:34 PDT
Comment on attachment 337880 [details]
Patch

Clearing flags on attachment: 337880

Committed r230629: <https://trac.webkit.org/changeset/230629>
Comment 3 WebKit Commit Bot 2018-04-13 06:18:36 PDT
All reviewed patches have been landed.  Closing bug.