Mesa (master): mesa: fix deleting the dummy ATI_fs

Marek Olšák mareko at kemper.freedesktop.org
Tue Nov 7 16:32:14 UTC 2017


Module: Mesa
Branch: master
Commit: cf47dfe8f18e5398dc55ead6c1495c14c3dec938
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=cf47dfe8f18e5398dc55ead6c1495c14c3dec938

Author: Miklós Máté <mtmkls at gmail.com>
Date:   Fri Nov  3 02:01:42 2017 +0100

mesa: fix deleting the dummy ATI_fs

The DummyShader is used by GenFragmentShadersATI() as a placeholder to
mark IDs as allocated. Context cleanup wants to delete everything in
ctx->Shared->ATIShaders, and crashes on these placeholders with this
backtrace:
==15060== Invalid free() / delete / delete[] / realloc()
==15060==    at 0x482F478: free (vg_replace_malloc.c:530)
==15060==    by 0x57694F4: _mesa_delete_ati_fragment_shader (atifragshader.c:68)
==15060==    by 0x58B33AB: delete_fragshader_cb (shared.c:208)
==15060==    by 0x5838836: _mesa_HashDeleteAll (hash.c:295)
==15060==    by 0x58B365F: free_shared_state (shared.c:377)
==15060==    by 0x58B3BC2: _mesa_reference_shared_state (shared.c:469)
==15060==    by 0x578687F: _mesa_free_context_data (context.c:1366)
==15060==    by 0x595E9EC: st_destroy_context (st_context.c:642)
==15060==    by 0x5987057: st_context_destroy (st_manager.c:772)
==15060==    by 0x5B018B6: dri_destroy_context (dri_context.c:217)
==15060==    by 0x5B006D3: driDestroyContext (dri_util.c:511)
==15060==    by 0x4A1CBE6: dri3_destroy_context (dri3_glx.c:170)
==15060==  Address 0x7b5dae0 is 0 bytes inside data symbol "DummyShader"

Also, DeleteFragmentShadersATI() should not assert on DummyShader, just
remove the hash entry.

Normally one would define a shader after GenFragmentShadersATI(), and
BindFragmentShaderATI() replaces the placeholder with a real object.
However, the specification doesn't say that one has to define a shader
for each allocated ID.

Signed-off-by: Miklós Máté <mtmkls at gmail.com>
Signed-off-by: Marek Olšák <marek.olsak at amd.com>

---

 src/mesa/main/atifragshader.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/atifragshader.c b/src/mesa/main/atifragshader.c
index 27d8b86477..49ddb6e5af 100644
--- a/src/mesa/main/atifragshader.c
+++ b/src/mesa/main/atifragshader.c
@@ -60,6 +60,10 @@ void
 _mesa_delete_ati_fragment_shader(struct gl_context *ctx, struct ati_fragment_shader *s)
 {
    GLuint i;
+
+   if (s == &DummyShader)
+      return;
+
    for (i = 0; i < MAX_NUM_PASSES_ATI; i++) {
       free(s->Instructions[i]);
       free(s->SetupInst[i]);
@@ -295,7 +299,6 @@ _mesa_DeleteFragmentShaderATI(GLuint id)
       if (prog) {
 	 prog->RefCount--;
 	 if (prog->RefCount <= 0) {
-	    assert(prog != &DummyShader);
             _mesa_delete_ati_fragment_shader(ctx, prog);
 	 }
       }




More information about the mesa-commit mailing list