Summary: | Endless loop in ralloc code | ||
---|---|---|---|
Product: | Mesa | Reporter: | s3734770 |
Component: | glsl-compiler | Assignee: | Ian Romanick <idr> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | blocker | ||
Priority: | medium | CC: | kenneth, pavel.ondracka |
Version: | git | ||
Hardware: | x86-64 (AMD64) | ||
OS: | Linux (All) | ||
Whiteboard: | |||
i915 platform: | i915 features: | ||
Attachments: | Patch: fixes the issue |
Description
s3734770
2011-02-01 07:52:25 UTC
I think this bug was fixed by the following commit. Please reopen the bug if that doesn't do it. commit a7d350790b4d0416117bc785aa77de52e9298a01 Author: Kenneth Graunke <kenneth@whitecape.org> Date: Tue Feb 1 00:20:01 2011 -0800 glsl: Fix memory error when creating the supported version string. Passing ralloc_vasprintf_append a 0-byte allocation doesn't work. If passed a non-NULL argument, ralloc calls strlen to find the end of the string. Since there's no terminating '\0', it runs off the end. Fixes a crash introduced in 14880a510a1a288df0778395097d5a52806abfb0. *** Bug 33809 has been marked as a duplicate of this bug. *** a7d350790b4d0416117bc785aa77de52e9298a01 does not fix the issue, I already tested after a7d350790b4d0416117bc785aa77de52e9298a01. char *supported = ralloc_strdup(this, ""); is optimized to NULL by GCC. I'm not able to write a workaround because GCC optimizes out all pre-checks. I think the bug is in strlen itself (the trivial '\0'), but it's only a presumption. - It also occurs when I use an other string value for the strdup call. - Alternative strlen implementations are also transformed into SSE2 "optimized" strlen. - setting existing_length to 0 leads to compile errors with builtin_function Created attachment 42849 [details] [review] Patch: fixes the issue ralloc_asprintf_append is not working correctly, so i replaced it by ralloc_asprintf and ralloc_strcat. This is insane. If your GCC is "optimizing" ralloc_strdup(this, "") to NULL, it is fundamentally broken. That call is supposed to allocate a chunk of memory containing a ralloc header followed by 1-byte of '\0'. Replacing a call to allocate 49 bytes or so with NULL is just completely wrong. Furthermore, ralloc_vasprintf_append checks for the supplied pointer being NULL and will fall back to ralloc_vasprintf. So even if it -were- NULL, it should still work. Finally, if supported is NULL (as you say), your patch should make things worse, not better. ralloc_strcat should assertion fail in that case. Though, since I assume you have assertions turned off, it would proceed to call strlen(NULL), which seems even less likely to work. Try a clean build. Maybe re-autogen. It's probably insane transitory breakage. Failing that, post your compiler version and optimization flags. gcc version 4.4.5 No matter what my compiler version and opt. flags are, you cannot expect from devs to set up a specific flag setting that this one optimization is not done that the code works. My patch does not leak memory, it keeps the semantic and follows the code style. It fixes the bug and Ivans commit is no longer a blocker. Are there any reasons left why not apply this? And don't try to reclose this bug till it's not fixed. oh sorry, you're right. After a reboot with an updated package and a rebuild it works fine. thanks for being patient |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.