Skip to content

Fix Valgrind uninitialized memory warning when running tests#508

Merged
Ghabry merged 1 commit intoEasyRPG:masterfrom
staticssleever668:fix_valgrind_tests
May 1, 2026
Merged

Fix Valgrind uninitialized memory warning when running tests#508
Ghabry merged 1 commit intoEasyRPG:masterfrom
staticssleever668:fix_valgrind_tests

Conversation

@staticssleever668
Copy link
Copy Markdown
Contributor

Conditional jump or move depends on uninitialised value(s)

> Conditional jump or move depends on uninitialised value(s)
@Ghabry
Copy link
Copy Markdown
Member

Ghabry commented Apr 25, 2026

Jenkins: Test this please <3

@Ghabry Ghabry added this to the 0.8.2 milestone Apr 25, 2026
Copy link
Copy Markdown
Member

@Ghabry Ghabry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx. Honestly not sure why its considered uninitialized but the errors are gone :)

@Ghabry
Copy link
Copy Markdown
Member

Ghabry commented May 1, 2026

Forwarded this change to Gemini to evaluate it: This appears to be a false positive in valgrind though I will continue merging it as it has no disadvantages.


Notable (I will fix this somewhere else) is that it also found a bug in flip_all:

While analyzing this file, I noticed an unrelated but highly likely bug in flip_all():
code
p[i] ^= p[i]; // <--- BUG
Any value XORed by itself is zero. Currently, flip_all() acts identically to reset_all() > (it clears all bits to 0 instead of inverting them).
To actually flip the bits, this should be written as p[i] = ~p[i]; or p[i] ^= 0xFF;.

Though this was never noticed as this function is never used and there is no unit test for it :)

@Ghabry Ghabry merged commit cb35691 into EasyRPG:master May 1, 2026
10 checks passed
@staticssleever668 staticssleever668 deleted the fix_valgrind_tests branch May 1, 2026 18:16
@staticssleever668
Copy link
Copy Markdown
Contributor Author

I don't think it's a false-positive, but it doesn't matter in practice either.
Memory is byte addressable. Even if we only assign and read the first n bits, we still fetch the whole byte that contains other, uninitialized bits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants