Mercurial > octave
changeset 28527:9e7b2625e574 stable
ov-java.cc: Set reaper thread to use default stack size (bug #58641).
* m4/acinclude.m4 (OCTAVE_CHECK_BROKEN_PTHREAD_STACKSIZE): New configure test.
* configure.ac: Run new configure test.
* ov-java.cc (initialize_jvm): Set jdk.lang.processReaperUseDefaultStackSize to
true if the new configure test failed (work around a glibc bug).
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Fri, 26 Jun 2020 18:44:35 +0200 |
parents | 286fe9352cd6 |
children | d5311ca8f945 7d601759c23d |
files | configure.ac libinterp/octave-value/ov-java.cc m4/acinclude.m4 |
diffstat | 3 files changed, 77 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/configure.ac Thu Jul 02 15:06:36 2020 +0900 +++ b/configure.ac Fri Jun 26 18:44:35 2020 +0200 @@ -563,6 +563,12 @@ CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" +dnl Check if glibc uses wrong stack size +OCTAVE_CHECK_BROKEN_PTHREAD_STACKSIZE +AM_CONDITIONAL([OCTAVE_CHECK_BROKEN_PTHREAD_STACKSIZE], + [test $octave_cv_broken_pthread_stacksize = yes]) + + ### Test whether the compiler supports OpenMP. dnl This is enabled by default to allow the option of using OpenMP in dnl loadable modules.
--- a/libinterp/octave-value/ov-java.cc Thu Jul 02 15:06:36 2020 +0900 +++ b/libinterp/octave-value/ov-java.cc Fri Jun 26 18:44:35 2020 +0200 @@ -766,6 +766,9 @@ // Hard-coded options for the jvm. vm_args.add ("-Djava.class.path=" + initial_class_path ()); +#if defined (HAVE_BROKEN_PTHREAD_STACKSIZE) + vm_args.add ("-Djdk.lang.processReaperUseDefaultStackSize=true"); +#endif vm_args.add ("-Xrs"); // Additional options given by file java.opts.
--- a/m4/acinclude.m4 Thu Jul 02 15:06:36 2020 +0900 +++ b/m4/acinclude.m4 Fri Jun 26 18:44:35 2020 +0200 @@ -187,6 +187,74 @@ fi ]) dnl +dnl Check if pthread stack size accounts for thread-local storage. +dnl +dnl This program should succeed if the pthread library allocates memory +dnl for thread-local (__thread) variables independently of the +dnl requested thread stack size. +dnl +dnl It will fail if (as in the current version of glibc) the storage +dnl for thread-local variables is subtracted from the memory allocated +dnl for the thread stack. (This can cause problems for Java and for +dnl other libraries.) +dnl +dnl This bug is tracked in glibc at: +dnl https://sourceware.org/bugzilla/show_bug.cgi?id=11787 +dnl +AC_DEFUN([OCTAVE_CHECK_BROKEN_PTHREAD_STACKSIZE], [ + AC_CACHE_CHECK([whether pthread stack size does not account for thread-local storage], + [octave_cv_broken_pthread_stacksize], + [AC_LANG_PUSH(C) + AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +#include <stdio.h> +#include <string.h> +#include <pthread.h> + +static char __thread data[100 * 1024]; + +static void * threadfunc(void *arg) +{ + return data; +} + ]], [[ + pthread_attr_t attr; + pthread_t thread; + int errnum; + + pthread_attr_init (&attr); + errnum = pthread_attr_setstacksize (&attr, 64 * 1024); + if (errnum != 0) + { + fprintf (stderr, "pthread_attr_setstacksize: %s\n", strerror(errnum)); + return 1; + } + errnum = pthread_create (&thread, &attr, &threadfunc, NULL); + if (errnum != 0) + { + fprintf (stderr, "pthread_create: %s\n", strerror(errnum)); + return 1; + } + errnum = pthread_join (thread, NULL); + if (errnum != 0) + { + fprintf (stderr, "pthread_join: %s\n", strerror(errnum)); + return 1; + } + + pthread_attr_destroy (&attr); + return 0; + ]])], + octave_cv_broken_pthread_stacksize=no, + octave_cv_broken_pthread_stacksize=yes, + octave_cv_broken_pthread_stacksize=no) + AC_LANG_POP(C) + ]) + if test $octave_cv_broken_pthread_stacksize = yes; then + AC_DEFINE(HAVE_BROKEN_PTHREAD_STACKSIZE, 1, + [Define to 1 if pthread stack size does not account for thread-local storage.]) + fi +]) +dnl dnl Check whether CXSparse is version 2.2 or later dnl FIXME: This test uses a version number. It potentially could dnl be re-written to actually call a function, but is it worth it?