On 12/10/2014 07:08 AM, Valentin Corfu wrote:
> 
> On 10.12.2014 07:02, Chad Versace wrote:
>> On 12/08/2014 01:45 PM, Ian Romanick wrote:
>>> On 12/02/2014 12:10 AM, Valentin Corfu wrote:
>>>> With this check we can avoid segmentation fault when invalid value used 
>>>> during eglCreateContext.
>>>>
>>>> Cc: mesa-sta...@lists.freedesktop.org
>>>> Cc: mesa-dev@lists.freedesktop.org
>>>> Signed-off-by: Valentin Corfu <valentinx.co...@intel.com>
>>>> ---
>>>>   src/egl/drivers/dri2/egl_dri2.c | 5 +++++
>>>>   1 file changed, 5 insertions(+)
>>>>
>>>> diff --git a/src/egl/drivers/dri2/egl_dri2.c 
>>>> b/src/egl/drivers/dri2/egl_dri2.c
>>>> index d795a2f..819cb77 100644
>>>> --- a/src/egl/drivers/dri2/egl_dri2.c
>>>> +++ b/src/egl/drivers/dri2/egl_dri2.c
>>>> @@ -808,6 +808,11 @@ dri2_create_context(_EGLDriver *drv, _EGLDisplay 
>>>> *disp, _EGLConfig *conf,
>>>>        (void) drv;
>>>>   +   if (conf == NULL) {
>>>> +      _eglError(EGL_BAD_CONFIG, "dri2_create_context");
>>>> +      return NULL;
>>>> +   }
>>>> +
>>> Can't conf be NULL when used with MESA_configless_context?  See also the
>>> conf != NULL check at line 853.
>>>
>>> Also, parameter validation etc. should go in eglCreateContext.
>> NAK. I don't know Valentin is hitting a segfault. But (conf == NULL) is
>> legal here. If Valentin has a backtrace, then maybe that would help us
>> determine a correct fix.
>>
>> This same function, farther below, contains this code:
>>
>> src/egl/drivers/dri2/egl_dri2.c:dri2_create_context():
>>      if (conf != NULL) {
>>          ...
>>      } else {
>>          dri_config = NULL;
>>      }
>>
>> And as Ian points out, the config is allowed to be null if 
>> EGL_MESA_configless_context
>> is supported. Here's proof:
>>                                                                              
>>         EGLContext EGLAPIENTRY
>> eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_list,
>>                   const EGLint *attrib_list)
>> {
>>     ...
>>                                                                              
>>             if (!config && !disp->Extensions.MESA_configless_context)
>>        RETURN_EGL_ERROR(disp, EGL_BAD_CONFIG, EGL_NO_CONTEXT);
>>         ...
>> }
>>
>>
>>
> 
> This problem starts when I call eglCreateContext in following way into 
> "simple-egl" app:
>     window->egl.ctx = eglCreateContext(window->egl.dpy, NULL, NULL, 
> context_attribs);
> 
> So in this way, I got a segfault into /usr/lib/dri/i965_dri.so library.
> (Unfortunately, I can't provide any backtrace.)
> 
> Also, I'm using an older version (9.1.1) and into eglCreateContext function, 
> RETURN_EGL_ERROR is not called.

It sounds like your fix is applicable to the version of Mesa that you're using 
(Mesa 9.1.1), but the fix is no
longer applicable to recent versions of Mesa. In fact, in recent Mesa this 
patch *creates* bugs instead of fixing them.

The Mesa 9.1 series has been end-of-lifed and upstream is no longer accepting 
bugfixes.

I suggest that:
  - If possible, you should upgrade to a more recent version of Mesa.
  - If you are unable to upgrade Mesa on your device (perhaps you're working on 
an
    embedded product), then you should submit your patch to the maintainer of 
your
    device's Linux distribution.

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to