mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 10:04:42 +02:00
8267908: linux: thread_native_entry can scribble on stack frame
Reviewed-by: ysuenaga
This commit is contained in:
parent
f40c89e8e9
commit
341f676066
1 changed files with 2 additions and 1 deletions
|
@ -672,7 +672,8 @@ static void *thread_native_entry(Thread *thread) {
|
||||||
// and we did not see any degradation in performance without `alloca()`.
|
// and we did not see any degradation in performance without `alloca()`.
|
||||||
static int counter = 0;
|
static int counter = 0;
|
||||||
int pid = os::current_process_id();
|
int pid = os::current_process_id();
|
||||||
void *stackmem = alloca(((pid ^ counter++) & 7) * 128);
|
int random = ((pid ^ counter++) & 7) * 128;
|
||||||
|
void *stackmem = alloca(random != 0 ? random : 1); // ensure we allocate > 0
|
||||||
// Ensure the alloca result is used in a way that prevents the compiler from eliding it.
|
// Ensure the alloca result is used in a way that prevents the compiler from eliding it.
|
||||||
*(char *)stackmem = 1;
|
*(char *)stackmem = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue