make sure that ListerThread runs on properly aligned stack

Without this fix we're failing unit tests on ubuntu 18.04 and centos 7
and 6. It looks like clone() in old glibc-s doesn't align stack, so
lets handle it ourselves. How we didn't hit this much earlier (before
massive thread listing refactoring), I am not sure. Most likely pure
luck(?)
This commit is contained in:
Aliaksey Kandratsenka 2023-08-09 23:29:00 -04:00
parent 51c5e2bec7
commit 729383b486

View File

@ -179,6 +179,7 @@ static int local_clone (int (*fn)(void *), void *arg) {
* correctly.
*/
uintptr_t stack_addr = reinterpret_cast<uintptr_t>(&arg) + clone_stack_size;
stack_addr &= ~63; // align stack address on 64 bytes (x86 needs 16, but lets be generous)
return clone(fn, reinterpret_cast<void*>(stack_addr),
CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_UNTRACED,
arg, 0, 0, 0);