summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2012-02-02 11:29:51 -0800
committerIan Romanick <ian.d.romanick@intel.com>2012-02-07 10:26:16 -0800
commit02962ea086abac01fdb9e4539db30e7c3bc0a4a4 (patch)
tree8698022225cfe758be23259773140c2257c6b67c
parent358389fe5954c69eb5d75e8c0d0caa9c12cd492b (diff)
downloadmesa-02962ea086abac01fdb9e4539db30e7c3bc0a4a4.tar.gz
glsl: Avoid ralloc_stealing a long-lived object to a short-lived parent
In commit 6ecee54a9aecc120cb68b02f7e14dcac86b9eca2 a call to talloc_reference was replaced with a call to talloc_steal. This was in preparation for moving to ralloc which doesn't support reference counting. The justification for talloc_steal within token_list_append in that commit is that the tokens are being copied already. But the copies are shallow, so this does not work. Fortunately, the lifetime of these tokens is easy to understand. A token list for "replacements" is created and stored in a hash table when a function-like macro is defined. This list will live until the macro is #undefed (if ever). Meanwhile, a shallow copy of the list is created when the macro is used and the list expanded. This copy is short-lived, so is unsuitable as a new parent. So we can just let the original, longer-lived owner continue to own the underlying objects and things will work. This fixes bug #45082: "ralloc.c:78: get_header: Assertion `info->canary == 0x5A1106' failed." when using a macro in GLSL https://bugs.freedesktop.org/show_bug.cgi?id=45082 Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> NOTE: This is a candidate for stable release branches. (cherry picked from commit cd2e2187cb45accb13bf89ef297324332c46f379)
-rw-r--r--src/glsl/glcpp/glcpp-parse.y3
1 files changed, 0 insertions, 3 deletions
diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index 2b7e65cd4e1..efcc205c2d3 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -85,7 +85,6 @@ _token_create_ival (void *ctx, int type, int ival);
static token_list_t *
_token_list_create (void *ctx);
-/* Note: This function calls ralloc_steal on token. */
static void
_token_list_append (token_list_t *list, token_t *token);
@@ -763,8 +762,6 @@ _token_list_append (token_list_t *list, token_t *token)
node->token = token;
node->next = NULL;
- ralloc_steal (list, token);
-
if (list->head == NULL) {
list->head = node;
} else {