Bug 97214 - X not running with error "Failed to make EGL context current"
Summary: X not running with error "Failed to make EGL context current"
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: EGL (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: mesa-dev
QA Contact: mesa-dev
URL:
Whiteboard:
Keywords: bisected
Depends on:
Blocks:
 
Reported: 2016-08-05 11:24 UTC by Alexandr Zelinsky
Modified: 2016-08-16 08:32 UTC (History)
4 users (show)

See Also:
i915 platform:
i915 features:


Attachments
xinit log with LIBGL_DEBUG=verbose (2.38 KB, text/plain)
2016-08-09 13:48 UTC, Alexandr Zelinsky
Details
EGL_LOG_LEVEL=debug (1.98 KB, text/plain)
2016-08-09 14:10 UTC, Alexandr Zelinsky
Details
Add tracing to egl_dri2.c (1.54 KB, patch)
2016-08-09 17:07 UTC, Nicolas Boichat
Details | Splinter Review
EGL_LOG_LEVEL=debug with patches (2.65 KB, text/plain)
2016-08-09 17:25 UTC, Alexandr Zelinsky
Details
More tracing in egl_dri2.c (1.86 KB, patch)
2016-08-09 18:26 UTC, Nicolas Boichat
Details | Splinter Review
Possible fix (614 bytes, patch)
2016-08-09 20:00 UTC, Nicolas Boichat
Details | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Alexandr Zelinsky 2016-08-05 11:24:26 UTC
bisected in commit 9ee683f877b283020c6f24776236f1145cb7a4ea
xorg log https://bpaste.net/show/1bede21ad143
Comment 1 Nicolas Boichat 2016-08-07 07:24:53 UTC
Not sure what's going on, but, as a first step, can you try to apply these 2 patches?

https://patchwork.freedesktop.org/patch/101934/
https://patchwork.freedesktop.org/patch/102770/
Comment 2 Alexandr Zelinsky 2016-08-07 11:48:05 UTC
didnt help 
same error
Comment 3 Nicolas Boichat 2016-08-09 09:30:19 UTC
Ok, thanks for trying those out.

Can you try again, setting LIBGL_DEBUG=verbose ? Hopefully that'll give us more logs and a better idea of what is going on...
Comment 4 Alexandr Zelinsky 2016-08-09 13:48:14 UTC
Created attachment 125637 [details]
xinit log with LIBGL_DEBUG=verbose

seems not very usefull
what your nickname on #dri-devel?
Comment 5 Michel Dänzer 2016-08-09 14:06:59 UTC
Try EGL_LOG_LEVEL=debug as well.
Comment 6 Alexandr Zelinsky 2016-08-09 14:10:02 UTC
Created attachment 125640 [details]
EGL_LOG_LEVEL=debug
Comment 7 Nicolas Boichat 2016-08-09 17:07:19 UTC
Created attachment 125643 [details] [review]
Add tracing to egl_dri2.c

libEGL debug: EGL user error 0x3001 (EGL_NOT_INITIALIZED) in eglMakeCurrent

Is due to the new code in dri2_make_current:
   if (!dri2_dpy)
      return _eglError(EGL_NOT_INITIALIZED, "eglMakeCurrent");

I don't quite understand how dri2_dpy could end up being uninitialized, unless eglMakeCurrent is called after eglTerminate...

I'd start by adding traces in dri2_initialize, dri2_terminate, dri2_make_current, which is what this patch does...
Comment 8 Alexandr Zelinsky 2016-08-09 17:25:09 UTC
Created attachment 125644 [details]
EGL_LOG_LEVEL=debug with patches
Comment 9 Nicolas Boichat 2016-08-09 18:26:46 UTC
Created attachment 125647 [details] [review]
More tracing in egl_dri2.c

I see. When the second display is initialized, there is still an active context, it seems (dri2_display_release should not be called on the first call to dri2_make_current):

libEGL debug: Native platform type: drm (autodetected)
libEGL debug: dri2_initialize 0x90d7a0 0x9a2f10 (dri2_dpy=(null))
libEGL debug: the best driver is DRI2
libEGL debug: EGL user error 0x3009 (EGL_BAD_MATCH) in dri2_create_context
libEGL debug: dri2_make_current 0x90d7a0 0x9a2f10 (nil) (nil) 0x99dbf0
libEGL debug: dri2_display_release 0x9a2f10 2
refcount -> 1

This causes the reference count to drop to zero later on:
libEGL debug: dri2_make_current 0x90d7a0 0x9a2f10 (nil) (nil) (nil)
libEGL debug: dri2_display_release 0x9a2f10 1
refcount -> 0 => display is destroyed
libEGL debug: dri2_make_current 0x90d7a0 0x9a2f10 (nil) (nil) 0x99dbf0
libEGL debug: EGL user error 0x3001 (EGL_NOT_INITIALIZED) in eglMakeCurrent

One more patch to confirm this.
Comment 10 Nicolas Boichat 2016-08-09 20:00:46 UTC
Created attachment 125652 [details] [review]
Possible fix

Possible fix attached, please give it a try. Thanks!
Comment 11 Alexandr Zelinsky 2016-08-09 23:25:02 UTC
fix working
if you need logs with last tracing patch https://bpaste.net/show/6b49674b4e26
Comment 12 Nicolas Boichat 2016-08-10 06:01:20 UTC
Patch on list here https://patchwork.freedesktop.org/patch/104229/, thanks for testing!
Comment 13 Michel Dänzer 2016-08-16 08:32:41 UTC
Module: Mesa
Branch: master
Commit: 78e3cea4197802253401766fc44362786898e024
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=78e3cea4197802253401766fc44362786898e024

Author: Nicolas Boichat <drinkcat@chromium.org>
Date:   Thu Aug 11 16:43:32 2016 +0800

egl/dri2: dri2_make_current: Release previous context's display


bug/show.html.tmpl processed on Feb 28, 2017 at 05:31:49.
(provided by the Example extension).