RFR(S): 8186293: [aix] Fix thread creation with huge stack sizes

Lindenmaier, Goetz goetz.lindenmaier at sap.com
Thu Aug 17 06:53:52 UTC 2017


Hi Thomas,

Thanks for the review!
I adapted the comment and removed the check after setting the guard size.

Best regards,
  Goetz.


From: Thomas Stüfe [mailto:thomas.stuefe at gmail.com]
Sent: Wednesday, August 16, 2017 4:43 PM
To: Lindenmaier, Goetz <goetz.lindenmaier at sap.com>
Cc: hotspot-runtime-dev at openjdk.java.net
Subject: Re: RFR(S): 8186293: [aix] Fix thread creation with huge stack sizes

Hi Goetz,

thanks for this fix! Some small nits:

"+ // On linux, pthread_attr_setstacksize succeeds with huge values, but
+  // pthread_create() fails.

No need to mention Linux here.

+   On Aix, this fails and leaves the minimal system
+  // thread size in attr."

We do not know this :) We only know it leaves the pthread_attr structure untouched. It was filled by pthread_attr_init() with default values. Stack default size may be minimally possible size, but I rather doubt this.

How about instead: "On Aix, this fails and leaves the pthread_attr structure untouched"

-  pthread_attr_setguardsize(&attr, os::Aix::default_guard_size(thr_type));
+    ret = pthread_attr_setguardsize(&attr, os::Aix::default_guard_size(thr_type));

I would not bother checking the setting of the guard page. The only reason it makes even sense to set the guard page size is for java threads, where we set it to zero because we do not want to spend memory for a system guard page if we have our own guard pages. See os::Aix::default_guard_size. For all other threads, this is supposed to be one page. But as a stack page may be 4 or 64k, this is flaky and may fail.

In fact, thinking about this, I think a better way to do this would to be to call pthread_attr_setguardsize() only to disable system guard pages, and to otherwise live with the system guard page default.

--

The rest is fine. I leave it up to you if you take my proposals. Do not need another webrev.

..Thomas



On Wed, Aug 16, 2017 at 4:24 PM, Lindenmaier, Goetz <goetz.lindenmaier at sap.com<mailto:goetz.lindenmaier at sap.com>> wrote:
Hi,

TestOptionWithRanges causes the vm on aix to crash on some machines.
This is because huge stack sizes are not treated properly.

On linux, pthread_attr_setstacksize succeeds if called with huge values, but
pthread_create() then fails. On Aix, pthread_attr_setstacksize  fails if
passed a value exceeding the limits and leaves the minimal system
thread stack size in attr. Thus thread creation succeeds and leads to
crashes after thread creation when the guard pages shall be protected
but don't fit on the tiny stack created.

Please review this small, aix-only change.
http://cr.openjdk.java.net/~goetz/wr17/8186293-aixHugeStack/webrev.01/

Best regards,
  Goetz.



More information about the hotspot-runtime-dev mailing list