mesa/src
Kenneth Graunke 7c5629a269 i965: Unbind deleted shaders from brw_context, fixing malloc heisenbug.
Applications may delete a shader program, create a new one, and bind it
before the next draw.  With terrible luck, malloc may randomly return a
chunk of memory for the new gl_program that happened to be the exact
same pointer as our previously bound gl_program.  In this case, our
logic to detect new programs in brw_upload_pipeline_state() would break:

      if (brw->vertex_program != ctx->VertexProgram._Current) {
         brw->vertex_program = ctx->VertexProgram._Current;
         brw->ctx.NewDriverState |= BRW_NEW_VERTEX_PROGRAM;
      }

Because the pointer is the same, we'd think it was the same program.
But it could be wildly different - a different stage altogether,
different sets of resources, and so on.  This causes utter chaos.

As unlikely as this seems, I believe I hit this when running a subset
of the CTS in a loop, in a group of tests that churns through simple
programs, deleting and rebuilding them.  Presumably malloc uses a
bucketing cache of sorts, and so freeing up a gl_program and allocating
a new one fairly quickly causes it to reuse that memory.

The result was that brw->vertex_program->info.num_ssbos claimed the
program had SSBOs, while brw->vs.base.prog_data.binding_table claimed
that there were none.  This was crazy, because the binding table is
calculated from info.num_ssbos - the shader info appeared to change
between shader compile time and draw time.  Careful use of watchpoints
revealed that it was being clobbered by rzalloc's memset when building
an entirely different program...

Fortunately, our 0xd0d0d0d0 canary for unused binding table entries
caused us to crash out of bounds when trying to upload SSBOs, or we
may have never discovered this heisenbug.

Fixes crashes in GL45-CTS.compute_shader.sso-case2 when using a hacked
cts-runner that only runs GL45-CTS.compute_shader.s* in EGL config ID 5
at 64x64 in a loop with 100 iterations.

Cc: "17.0 13.0 12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-01-27 21:52:37 -08:00
..
amd radv/ac: Use base in push constant loads. 2017-01-28 03:07:39 +01:00
compiler glsl: remove explicit __STDC_FORMAT_MACROS define 2017-01-27 17:56:57 +00:00
egl egl: automake: include builddir prior to srcdir 2017-01-27 17:56:55 +00:00
gallium nouveau: remove explicit __STDC_FORMAT_MACROS define 2017-01-27 17:56:57 +00:00
gbm gbm/dri: fix memory leaks in error path 2017-01-27 17:56:58 +00:00
getopt Introduce .editorconfig 2016-08-31 17:06:54 -07:00
glx glx/windows: automake: include builddir prior to srcdir 2017-01-27 17:56:55 +00:00
gtest gtest: Update to 1.8.0. 2017-01-20 11:40:52 -08:00
hgl glapi/hgl: remove the final user of _glapi_check_table() 2016-10-06 15:03:46 +01:00
intel anv: Advertise API version 1.0.39 2017-01-27 10:06:14 -08:00
loader loader: automake: include builddir prior to srcdir 2017-01-27 17:56:56 +00:00
mapi mapi: automake: include builddir prior to srcdir 2017-01-27 17:56:56 +00:00
mesa i965: Unbind deleted shaders from brw_context, fixing malloc heisenbug. 2017-01-27 21:52:37 -08:00
util utils: really remove the __END_DECLS macro 2017-01-18 20:09:57 +00:00
vulkan vulkan/wsi: Lower the maximum image sizes 2017-01-25 09:05:30 -08:00
Makefile.am vulkan: automake: do not use EXTRA_DIST in a conditional 2017-01-18 13:41:32 +00:00
SConscript scons: put the generated git_sha1.h file in top-level src/ directory 2016-06-17 10:33:00 -06:00