From: bugzilla-daemon@freedesktop.org Subject: [Bug 98172] Concurrent call to glClientWaitSync results in segfault in one of the waiters. Date: Sun, 09 Oct 2016 17:04:19 +0000 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1298825735==" Return-path: Received: from culpepper.freedesktop.org (culpepper.freedesktop.org [IPv6:2610:10:20:722:a800:ff:fe98:4b55]) by gabe.freedesktop.org (Postfix) with ESMTP id 6EDD989623 for ; Sun, 9 Oct 2016 17:04:19 +0000 (UTC) List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============1298825735== Content-Type: multipart/alternative; boundary="14760326590.cb445D.21357"; charset="UTF-8" --14760326590.cb445D.21357 Date: Sun, 9 Oct 2016 17:04:19 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://bugs.freedesktop.org/ Auto-Submitted: auto-generated https://bugs.freedesktop.org/show_bug.cgi?id=3D98172 Bug ID: 98172 Summary: Concurrent call to glClientWaitSync results in segfault in one of the waiters. Product: Mesa Version: 11.2 Hardware: Other OS: All Status: NEW Severity: normal Priority: medium Component: Drivers/Gallium/r600 Assignee: dri-devel@lists.freedesktop.org Reporter: shinji.suzuki@gmail.com QA Contact: dri-devel@lists.freedesktop.org In my app, a fence is created in Thread-A and it gets passed to Thread-B and Thread-C to be waited upon. (Each thread has its own context.) Thread-A issues the call, fence =3D glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLE= TE, 0). Thread-B and C issue the call, glClientWaitSync(fence, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED); Most of the time, wait in both clients succeed but occasionally one of them generates segfault. Upon inspection of generated core, it turned out so->fe= nce in the expression "&so->fence" at line 113 in src/mesa/state_tracker/st_cb_syncobj.c is NULL, which should be causing the segfault down the call chain through screen->fence_reference. I think there= is race in executing the code block. If I introduce a mutex in my app with whi= ch to avoid concurrent call to glClientWaitSync, I don't observe segfault happening. Here is the snippet of code in question from st_cb_syncobj.c: if (so->fence && screen->fence_finish(screen, so->fence, timeout)) { screen->fence_reference(screen, &so->fence, NULL); so->b.StatusFlag =3D GL_TRUE; } My environment is; Ubuntu 16.04 LTS Linux a7da 4.4.0-38-generic #57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016 x86_= 64 x86_64 x86_64 GNU/Linux libgl1-mesa-dri:amd64 / 11.2.0-1ubuntu2.2 Radeon HD3300 --=20 You are receiving this mail because: You are the assignee for the bug.= --14760326590.cb445D.21357 Date: Sun, 9 Oct 2016 17:04:19 +0000 MIME-Version: 1.0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://bugs.freedesktop.org/ Auto-Submitted: auto-generated
Bug ID 98172
Summary Concurrent call to glClientWaitSync results in segfault in on= e of the waiters.
Product Mesa
Version 11.2
Hardware Other
OS All
Status NEW
Severity normal
Priority medium
Component Drivers/Gallium/r600
Assignee dri-devel@lists.freedesktop.org
Reporter shinji.suzuki@gmail.com
QA Contact dri-devel@lists.freedesktop.org

In my app, a fence is created in Thread-A and it gets passed t=
o Thread-B and
Thread-C to be waited upon. (Each thread has its own context.)
Thread-A issues the call, fence =3D glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLE=
TE,
0).
Thread-B and C issue the call, glClientWaitSync(fence,
GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED);

Most of the time, wait in both clients succeed but occasionally one of them
generates segfault. Upon inspection of generated core, it turned out so->=
;fence
in the expression "&so->fence" at line 113 in
src/mesa/state_tracker/st_cb_syncobj.c is NULL, which should be causing the
segfault down the call chain through screen->fence_reference. I think th=
ere is
race in executing the code block. If I introduce a mutex in my app with whi=
ch
to avoid concurrent call to glClientWaitSync, I don't observe segfault
happening.
Here is the snippet of code in question from st_cb_syncobj.c:

   if (so->fence &&
       screen->fence_finish(screen, so->fence, timeout)) {
      screen->fence_reference(screen, &so->fence, NULL);
      so->b.StatusFlag =3D GL_TRUE;
   }

My environment is;
Ubuntu 16.04 LTS
Linux a7da 4.4.0-38-generic #57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016 x86_=
64
x86_64 x86_64 GNU/Linux
libgl1-mesa-dri:amd64 / 11.2.0-1ubuntu2.2
Radeon HD3300


You are receiving this mail because:
  • You are the assignee for the bug.
= --14760326590.cb445D.21357-- --===============1298825735== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============1298825735==--