Skip to content

Commit

Permalink
8267908: linux: thread_native_entry can scribble on stack frame
Browse files Browse the repository at this point in the history
Reviewed-by: ysuenaga
  • Loading branch information
David Holmes committed Jun 8, 2021
1 parent f40c89e commit 341f676
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/hotspot/os/linux/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,8 @@ static void *thread_native_entry(Thread *thread) {
// and we did not see any degradation in performance without `alloca()`.
static int counter = 0;
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.
*(char *)stackmem = 1;
#endif
Expand Down

0 comments on commit 341f676

Please sign in to comment.