Skip to content

Commit 341f676

Browse files
author
David Holmes
committed
8267908: linux: thread_native_entry can scribble on stack frame
Reviewed-by: ysuenaga
1 parent f40c89e commit 341f676

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/hotspot/os/linux/os_linux.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,8 @@ static void *thread_native_entry(Thread *thread) {
672672
// and we did not see any degradation in performance without `alloca()`.
673673
static int counter = 0;
674674
int pid = os::current_process_id();
675-
void *stackmem = alloca(((pid ^ counter++) & 7) * 128);
675+
int random = ((pid ^ counter++) & 7) * 128;
676+
void *stackmem = alloca(random != 0 ? random : 1); // ensure we allocate > 0
676677
// Ensure the alloca result is used in a way that prevents the compiler from eliding it.
677678
*(char *)stackmem = 1;
678679
#endif

0 commit comments

Comments
 (0)