Re: [Mesa-dev] [PATCH 3/3] glsl_compiler: Add binding hash tables to avoid SIGSEVs on linking stage
On 11/18/2014 07:40 AM, Brian Paul wrote: > Thanks for splitting up the patch. Your commit message below line wraps > a bit short (~70 chars is about right). I'll fix that before pushing. You can add Reviewed-by: Ian Romanick to patches 2 and 3 too. > -Brian > > > On 11/18/2014 06:49 AM, Andres Gomez wrote: >> When using the stand alone compiler, if we try to >> link a shader with vertex attributes it will >> segfault on linking as the binding hash tables are >> not included in the shader program. Obviously, we >> cannot make the linking stage succeed without the >> bound attributes but we can prevent the crash and >> just let the linker spit its own error. >> --- >> src/glsl/main.cpp | 10 ++ >> 1 file changed, 10 insertions(+) >> >> diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp >> index 9b36a1f..91e457a 100644 >> --- a/src/glsl/main.cpp >> +++ b/src/glsl/main.cpp >> @@ -35,6 +35,7 @@ >> #include "glsl_parser_extras.h" >> #include "ir_optimization.h" >> #include "program.h" >> +#include "program/hash_table.h" >> #include "loop_analysis.h" >> #include "standalone_scaffolding.h" >> >> @@ -357,6 +358,11 @@ main(int argc, char **argv) >> assert(whole_program != NULL); >> whole_program->InfoLog = ralloc_strdup(whole_program, ""); >> >> + /* Created just to avoid segmentation faults */ >> + whole_program->AttributeBindings = new string_to_uint_map; >> + whole_program->FragDataBindings = new string_to_uint_map; >> + whole_program->FragDataIndexBindings = new string_to_uint_map; >> + >> for (/* empty */; argc > optind; optind++) { >> whole_program->Shaders = >>reralloc(whole_program, whole_program->Shaders, >> @@ -415,6 +421,10 @@ main(int argc, char **argv) >> for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) >> ralloc_free(whole_program->_LinkedShaders[i]); >> >> + delete whole_program->AttributeBindings; >> + delete whole_program->FragDataBindings; >> + delete whole_program->FragDataIndexBindings; >> + >> ralloc_free(whole_program); >> _mesa_glsl_release_types(); >> _mesa_glsl_release_builtin_functions(); >> > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/3] glsl_compiler: Add binding hash tables to avoid SIGSEVs on linking stage
Thanks for splitting up the patch. Your commit message below line wraps a bit short (~70 chars is about right). I'll fix that before pushing. -Brian On 11/18/2014 06:49 AM, Andres Gomez wrote: When using the stand alone compiler, if we try to link a shader with vertex attributes it will segfault on linking as the binding hash tables are not included in the shader program. Obviously, we cannot make the linking stage succeed without the bound attributes but we can prevent the crash and just let the linker spit its own error. --- src/glsl/main.cpp | 10 ++ 1 file changed, 10 insertions(+) diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 9b36a1f..91e457a 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -35,6 +35,7 @@ #include "glsl_parser_extras.h" #include "ir_optimization.h" #include "program.h" +#include "program/hash_table.h" #include "loop_analysis.h" #include "standalone_scaffolding.h" @@ -357,6 +358,11 @@ main(int argc, char **argv) assert(whole_program != NULL); whole_program->InfoLog = ralloc_strdup(whole_program, ""); + /* Created just to avoid segmentation faults */ + whole_program->AttributeBindings = new string_to_uint_map; + whole_program->FragDataBindings = new string_to_uint_map; + whole_program->FragDataIndexBindings = new string_to_uint_map; + for (/* empty */; argc > optind; optind++) { whole_program->Shaders = reralloc(whole_program, whole_program->Shaders, @@ -415,6 +421,10 @@ main(int argc, char **argv) for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) ralloc_free(whole_program->_LinkedShaders[i]); + delete whole_program->AttributeBindings; + delete whole_program->FragDataBindings; + delete whole_program->FragDataIndexBindings; + ralloc_free(whole_program); _mesa_glsl_release_types(); _mesa_glsl_release_builtin_functions(); ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/3] glsl_compiler: Add binding hash tables to avoid SIGSEVs on linking stage
When using the stand alone compiler, if we try to link a shader with vertex attributes it will segfault on linking as the binding hash tables are not included in the shader program. Obviously, we cannot make the linking stage succeed without the bound attributes but we can prevent the crash and just let the linker spit its own error. --- src/glsl/main.cpp | 10 ++ 1 file changed, 10 insertions(+) diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index 9b36a1f..91e457a 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -35,6 +35,7 @@ #include "glsl_parser_extras.h" #include "ir_optimization.h" #include "program.h" +#include "program/hash_table.h" #include "loop_analysis.h" #include "standalone_scaffolding.h" @@ -357,6 +358,11 @@ main(int argc, char **argv) assert(whole_program != NULL); whole_program->InfoLog = ralloc_strdup(whole_program, ""); + /* Created just to avoid segmentation faults */ + whole_program->AttributeBindings = new string_to_uint_map; + whole_program->FragDataBindings = new string_to_uint_map; + whole_program->FragDataIndexBindings = new string_to_uint_map; + for (/* empty */; argc > optind; optind++) { whole_program->Shaders = reralloc(whole_program, whole_program->Shaders, @@ -415,6 +421,10 @@ main(int argc, char **argv) for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) ralloc_free(whole_program->_LinkedShaders[i]); + delete whole_program->AttributeBindings; + delete whole_program->FragDataBindings; + delete whole_program->FragDataIndexBindings; + ralloc_free(whole_program); _mesa_glsl_release_types(); _mesa_glsl_release_builtin_functions(); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev