mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
unix: Prevent compiler optimization to ignore our memset to zero
It's well known that memset may be optimized out by compilers and this is one of these cases that freebsd CI highlighted. To prevent this to happen we should use memset_explicit() but that's C23, so till we don't support that, let's re-implement that ourself making the compiler not to optimize our memset's. In theory we could just rely on C11's memset_s, but that's not working either in freebsd.
This commit is contained in:
parent
035c318324
commit
3d474bd8c1
@ -593,6 +593,10 @@ test_signal_alternate_stack (int signal)
|
||||
*/
|
||||
g_assert_cmpint (memcmp (stack_memory, zero_mem, MINSIGSTKSZ), !=, 0);
|
||||
|
||||
/* We need to memset again zero_mem since compiler may have optimized it out
|
||||
* as we've seen in freebsd CI.
|
||||
*/
|
||||
memset (zero_mem, 0, MINSIGSTKSZ);
|
||||
memset (stack_memory, 0, MINSIGSTKSZ);
|
||||
g_assert_cmpmem (stack_memory, MINSIGSTKSZ, zero_mem, MINSIGSTKSZ);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user