From 5ff42d14294199eb3bf10b66530f9249fb68810d Mon Sep 17 00:00:00 2001 From: Varada M <mvarada2000@gmail.com> Date: Mon, 26 Jun 2023 14:28:40 +0000 Subject: [PATCH] 8303549: [AIX] TestNativeStack.java is failing with exit value 1 Reviewed-by: dholmes, gziemski --- .../runtime/jni/getCreatedJavaVMs/exeGetCreatedJavaVMs.c | 7 ++++++- .../jtreg/runtime/jni/nativeStack/libnativeStack.c | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/runtime/jni/getCreatedJavaVMs/exeGetCreatedJavaVMs.c b/test/hotspot/jtreg/runtime/jni/getCreatedJavaVMs/exeGetCreatedJavaVMs.c index a6fe23851f4..6c2b1ec5d91 100644 --- a/test/hotspot/jtreg/runtime/jni/getCreatedJavaVMs/exeGetCreatedJavaVMs.c +++ b/test/hotspot/jtreg/runtime/jni/getCreatedJavaVMs/exeGetCreatedJavaVMs.c @@ -89,14 +89,19 @@ void *thread_runner(void *threadid) { int main (int argc, char* argv[]) { pthread_t threads[NUM_THREADS]; + pthread_attr_t attr; + pthread_attr_init(&attr); + size_t stack_size = 0x100000; + pthread_attr_setstacksize(&attr, stack_size); for (int i = 0; i < NUM_THREADS; i++ ) { printf("[*] Creating thread %d\n", i); - int status = pthread_create(&threads[i], NULL, thread_runner, (void *)(intptr_t)i); + int status = pthread_create(&threads[i], &attr, thread_runner, (void *)(intptr_t)i); if (status != 0) { printf("[*] Error creating thread %d - %d\n", i, status); exit(-1); } } + pthread_attr_destroy(&attr); for (int i = 0; i < NUM_THREADS; i++ ) { pthread_join(threads[i], NULL); } diff --git a/test/hotspot/jtreg/runtime/jni/nativeStack/libnativeStack.c b/test/hotspot/jtreg/runtime/jni/nativeStack/libnativeStack.c index 4087e874c93..1da49f586d3 100644 --- a/test/hotspot/jtreg/runtime/jni/nativeStack/libnativeStack.c +++ b/test/hotspot/jtreg/runtime/jni/nativeStack/libnativeStack.c @@ -109,11 +109,18 @@ Java_TestNativeStack_triggerJNIStackTrace warning = warn; - if ((res = pthread_create(&thread, NULL, thread_start, NULL)) != 0) { + pthread_attr_t attr; + pthread_attr_init(&attr); + size_t stack_size = 0x100000; + pthread_attr_setstacksize(&attr, stack_size); + + if ((res = pthread_create(&thread, &attr, thread_start, NULL)) != 0) { fprintf(stderr, "TEST ERROR: pthread_create failed: %s (%d)\n", strerror(res), res); exit(1); } + pthread_attr_destroy(&attr); + if ((res = pthread_join(thread, NULL)) != 0) { fprintf(stderr, "TEST ERROR: pthread_join failed: %s (%d)\n", strerror(res), res); exit(1);