GNOME Bugzilla – Bug 654440
_cogl_winsys_context_init crash
Last modified: 2011-07-18 14:43:14 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;
can confirm the patch fixes a crasher with Cogl master on OSX.
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.
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.
attachment 191900 [details] [review] works as well on OSX.
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!
I've pushed the last patch as 231be91fb0. Thanks.