After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 763168 - gldisplay: _get_gl_context_for_thread_unlocked looks suspicious
gldisplay: _get_gl_context_for_thread_unlocked looks suspicious
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal normal
: 1.7.91
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-03-06 10:02 UTC by Mark Nauwelaerts
Modified: 2016-03-11 15:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gldisplay: really retrieve glcontext for a specific thread (938 bytes, patch)
2016-03-06 10:02 UTC, Mark Nauwelaerts
none Details | Review
gldisplay: really retrieve glcontext for a specific thread (994 bytes, patch)
2016-03-06 10:41 UTC, Mark Nauwelaerts
committed Details | Review

Description Mark Nauwelaerts 2016-03-06 10:02:15 UTC
Created attachment 323187 [details] [review]
gldisplay: really retrieve glcontext for a specific thread

See attached patch for the minor change; which unless I am missing the point should make the function really do as intended (whereas it now might fail to retrieve desired context).  Impact presently seems minor due to the limited code paths (and parameters) it is invoked.
Comment 1 Matthew Waters (ystreet00) 2016-03-06 10:30:42 UTC
Review of attachment 323187 [details] [review]:

Still not quite right.

::: gst-libs/gst/gl/gstgldisplay.c
@@ +440,2 @@
     context_thread = gst_gl_context_get_thread (context);
+    if (thread != NULL && thread != context_thread) {

Both before and after these changes aren't quite correct.

Before is definitely wrong.
After, if thread and all context_thread's are all NULL, then no context will be returned.

This should probably be something like this instead:

if (thread == NULL)
return context;

context_thread = gst_gl_context_get_thread (context);
if (thread != context_thread) {
...

Or invert the (thread != context_thread) and switch the continue/later return code paths
Comment 2 Mark Nauwelaerts 2016-03-06 10:41:51 UTC
Created attachment 323189 [details] [review]
gldisplay: really retrieve glcontext for a specific thread

Oops, indeed.  Modified patch along suggested lines ...
Comment 3 Matthew Waters (ystreet00) 2016-03-06 10:59:49 UTC
Review of attachment 323189 [details] [review]:

Some explanation in the commit message on why this is needed would be nice :)
Comment 4 Mark Nauwelaerts 2016-03-06 11:32:32 UTC
commit e38af2304427db908a16bbae0e60aa68be1ba5b5
Author: Mark Nauwelaerts <mnauw@users.sourceforge.net>
Date:   Sat Mar 5 17:16:24 2016 +0100

    gldisplay: really retrieve glcontext for a specific thread
    
    When requesting a glcontext (regardless of thread), the result was correct.
    However, when requesting current glcontext on a specific thread, it could
    come up with a glcontext active on another thread.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=763168