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 654440 - _cogl_winsys_context_init crash
_cogl_winsys_context_init crash
Status: RESOLVED FIXED
Product: cogl
Classification: Platform
Component: GL
git master
Other All
: Normal critical
: ---
Assigned To: Cogl maintainer(s)
Cogl maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2011-07-12 07:59 UTC by Bill Kelly
Modified: 2011-07-18 14:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Combine _cogl_context_check_gl_version and update_features into one (12.01 KB, patch)
2011-07-13 17:34 UTC, Neil Roberts
none Details | Review
Combine _cogl_context_check_gl_version and update_features into one (12.39 KB, patch)
2011-07-13 23:59 UTC, Neil Roberts
none Details | Review

Description Bill Kelly 2011-07-12 07:59:16 UTC
In cogl/winsys/cogl-winsys-stub.c , _cogl_context_update_features
needs to occur before _cogl_context_check_gl_version is called.
Otherwise ctx->glGetString() will be function call through NULL
pointer.

diff --git a/cogl/winsys/cogl-winsys-stub.c b/cogl/winsys/cogl-winsys-stub.c
index f6a2b41..3c40b03 100644
--- a/cogl/winsys/cogl-winsys-stub.c
+++ b/cogl/winsys/cogl-winsys-stub.c
@@ -83,11 +83,11 @@ _cogl_winsys_context_init (CoglContext *context, GError **error)
 {
   context->winsys = &_cogl_winsys_stub_dummy_ptr;

+  _cogl_context_update_features (context);
+
   if (!_cogl_context_check_gl_version (context, error))
     return FALSE;

-  _cogl_context_update_features (context);
-
   memset (context->winsys_features, 0, sizeof (context->winsys_features));

   return TRUE;
Comment 1 Emmanuele Bassi (:ebassi) 2011-07-13 17:06:34 UTC
can confirm the patch fixes a crasher with Cogl master on OSX.
Comment 2 Neil Roberts 2011-07-13 17:34:16 UTC
Thanks for the patch. I think it might be better to combine
_cogl_context_update_features and _cogl_context_check_gl_version into one
function because the other winsys backends seem to have forgotten to call
check_gl_version so that is why they don't crash. If we combine them into one
then it's less to remember when implementing a new winsys backend.
Comment 3 Neil Roberts 2011-07-13 17:34:53 UTC
Created attachment 191900 [details] [review]
Combine _cogl_context_check_gl_version and update_features into one

The _cogl_context_check_gl_version function is meant to be called once
Cogl has a GL context so that it can check whether the context found
is supported by Cogl. However, only the stub winsys was calling this
and it was doing it before Cogl had a chance to retrieve the function
pointer for glString so it would just crash. This patch combines the
two functions into one so that _cogl_context_update_features returns a
gboolean and a GError. Then it can just check the context itself.
Comment 4 Emmanuele Bassi (:ebassi) 2011-07-13 18:15:43 UTC
attachment 191900 [details] [review] works as well on OSX.
Comment 5 Neil Roberts 2011-07-13 23:59:20 UTC
Created attachment 191931 [details] [review]
Combine _cogl_context_check_gl_version and update_features into one

Minor fix of the patch for the EGL backend. oops!
Comment 6 Neil Roberts 2011-07-18 14:43:14 UTC
I've pushed the last patch as 231be91fb0. Thanks.