-
Notifications
You must be signed in to change notification settings - Fork 826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
memory corruption when encoding images with hextree #1087
Comments
latest backtrace looking a bit like: #948 |
The above commit fixes the testcase. Valgrind output at https://gist.github.com/1880708 helped point me to this fix, but this needs further review. /cc @mrudowski1 && @artemp /cc @yhahn for testing help. |
re-opening and providing another, yet simplified testcase, because my "fix" in 5dee576 needs to be better understood before we call this done. |
New C++ testcase using nothing but a single image (along with setup instructions): https://gist.github.com/1886226 |
Things I've tried that have been unsuccessful in revealing the root cause:
And here are the printed trees leading up to the crash: https://gist.github.com/1886745 |
starting to look like a problem in the function passed to sort, as it does not conform to the strict weak ordering requirement: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=553#c6 |
Another workaround appears to be to downgrade the gcc/g++ version used on oneiric:
|
4a192c3 fixes for g++ 4.6 on ubuntu oneiric |
Note that the reason for this bug was that the bool compare(const rgba& x, const rgba& y) {
int t1 = (int)x.a + x.r + x.g + x.b;
int t2 = (int)y.a + y.r + y.g + y.b;
if (t1 != t2) return t1 < t2;
return (((int)x.a - y.a) >> 24) +
(((int)x.r - y.r) >> 16) +
(((int)x.g - y.g) >> 8) +
(((int)x.b - y.b));
} The strict weak ordering criterion means that if you have three items a, b, c: a ≮ b ∧ b ≮ c ⟹ a ≮ c. The second part of the old function didn't fulfill that criterion. To get past the first if, a, b and c's rgba values have to add up to the same number. To trigger a violation of the strict weak ordering, take this example (in a/r/g/b order):
When comparing a and b, |
Crashes are variable, but here is a common one:
The text was updated successfully, but these errors were encountered: