mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-28 23:20:08 +01:00
glsl/linker: Validate IR just before reparenting.
If reparent_ir() is called on invalid IR, then there's a danger that it will fail to reparent all of the necessary nodes. For example, if the IR contains an ir_dereference_variable which refers to an ir_variable that's not in the tree, that ir_variable won't get reparented, resulting in subtle use-after-free bugs once the non-reparented nodes are freed. (This is exactly what happened in the bug fixed by the previous commit). This patch makes this kind of bug far easier to track down, by transforming it from a use-after-free bug into an explicit IR validation error. Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
parent
9dfcb05fa6
commit
d7fa9eb003
1 changed files with 5 additions and 0 deletions
|
|
@ -2396,6 +2396,11 @@ done:
|
|||
if (prog->_LinkedShaders[i] == NULL)
|
||||
continue;
|
||||
|
||||
/* Do a final validation step to make sure that the IR wasn't
|
||||
* invalidated by any modifications performed after intrastage linking.
|
||||
*/
|
||||
validate_ir_tree(prog->_LinkedShaders[i]->ir);
|
||||
|
||||
/* Retain any live IR, but trash the rest. */
|
||||
reparent_ir(prog->_LinkedShaders[i]->ir, prog->_LinkedShaders[i]->ir);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue