[Mesa-dev] Double free error on etnaviv driver.
Nazarov Sergey
s-nazarov at yandex.ru
Wed Jan 16 10:34:00 UTC 2019
Hello!
I use mesa+etnaviv Gallium driver on iMX6Q based board.
I have double free error at the end of any application using mesa.
I've found that the problem comes from current ARM g++ compilers
(at least from 4.9.4 up to latest ones) which call static objects destructors before
on_exit handler. So, static builtin_builder builtins destructor frees dynamically allocated
internal members memory before call of _mesa_glsl_release_builtin_functions(),
which do that again. Here is a patch to fix the problem:
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -6268,7 +6268,7 @@ builtin_builder::_vote(const char *intri
/******************************************************************************/
/* The singleton instance of builtin_builder. */
-static builtin_builder builtins;
+static builtin_builder *builtins = NULL;
static mtx_t builtins_lock = _MTX_INITIALIZER_NP;
/**
@@ -6279,7 +6279,9 @@ void
_mesa_glsl_initialize_builtin_functions()
{
mtx_lock(&builtins_lock);
- builtins.initialize();
+ if (!builtins)
+ builtins = new builtin_builder;
+ builtins->initialize();
mtx_unlock(&builtins_lock);
}
@@ -6287,7 +6289,9 @@ void
_mesa_glsl_release_builtin_functions()
{
mtx_lock(&builtins_lock);
- builtins.release();
+ builtins->release();
+ delete builtins;
+ builtins = NULL;
mtx_unlock(&builtins_lock);
}
@@ -6297,7 +6301,7 @@ _mesa_glsl_find_builtin_function(_mesa_g
{
ir_function_signature *s;
mtx_lock(&builtins_lock);
- s = builtins.find(state, name, actual_parameters);
+ s = builtins->find(state, name, actual_parameters);
mtx_unlock(&builtins_lock);
return s;
@@ -6309,7 +6313,7 @@ _mesa_glsl_has_builtin_function(_mesa_gl
ir_function *f;
bool ret = false;
mtx_lock(&builtins_lock);
- f = builtins.shader->symbols->get_function(name);
+ f = builtins->shader->symbols->get_function(name);
if (f != NULL) {
foreach_in_list(ir_function_signature, sig, &f->signatures) {
if (sig->is_builtin_available(state)) {
@@ -6326,7 +6330,7 @@ _mesa_glsl_has_builtin_function(_mesa_gl
gl_shader *
_mesa_glsl_get_builtin_function_shader()
{
- return builtins.shader;
+ return builtins ? builtins->shader : NULL;
}
More information about the mesa-dev
mailing list