Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix GH-9068: Conditional jump or move depends on uninitialised value(s)
This patch preserves the scratch registers of the SysV x86-64 ABI by storing them to the stack and restoring them later. We need to do this to prevent the registers of the caller from being corrupted. The reason these get corrupted is because the compiler is unaware of the Valgrind replacement function and thus makes assumptions about the original function regarding registers which are not true for the replacement function. For implementation I used a GCC and Clang attribute. A more general approach would be to use inline assembly but that's also less portable and quite hacky. This attributes is supported since GCC 7.x, but the target option is only supported since 11.x. For Clang the target option does not matter. Closes GH-10221.
- Loading branch information
4ca8daf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit will degrade the performance on Valgrind runs only, but not on production or development builds that don't involve Valgrind.
This is because with this patch all the caller saved registers are pushed on the stack before calling
memcmp
, and after the call popped again.This message is a heads up for the people running benchmarks. cc @iluuu1994 @dstogov