- DBG("Default pthread stack size is %zu bytes", ptstacksize);
-
- /* Check if the default pthread stack size honors ulimits. */
- if (ptstacksize < rlim.rlim_cur) {
- DBG("Your libc doesn't honor stack size limits, setting thread stack size to soft limit (%lld bytes)",
- (long long) rlim.rlim_cur);
-
- /* Create pthread_attr_t struct with ulimit stack size. */
- ret = pthread_attr_setstacksize(&tattr, rlim.rlim_cur);
- if (ret < 0) {
- PERROR("pthread_attr_setstacksize");
- goto error;
- }
+ DBG("Default pthread stack size is %zu bytes", pthread_ss);
+
+ selected_ss = max_t(size_t, pthread_ss, system_ss);
+ if (selected_ss < DEFAULT_LTTNG_THREAD_STACK_SIZE) {
+ DBG("Default stack size is too small, setting it to %zu bytes",
+ (size_t) DEFAULT_LTTNG_THREAD_STACK_SIZE);
+ selected_ss = DEFAULT_LTTNG_THREAD_STACK_SIZE;
+ }
+
+ if (rlim.rlim_max > 0 && selected_ss > rlim.rlim_max) {
+ WARN("Your system's stack size restrictions (%zu bytes) may be too low for the LTTng daemons to function properly, please set the stack size limit to at least %zu bytes to ensure reliable operation",
+ (size_t) rlim.rlim_max, (size_t) DEFAULT_LTTNG_THREAD_STACK_SIZE);
+ selected_ss = (size_t) rlim.rlim_max;