1854 }
1855
1856
1857 static const char* get_signal_handler_name(address handler,
1858 char* buf, int buflen) {
1859 int offset;
1860 bool found = os::dll_address_to_library_name(handler, buf, buflen, &offset);
1861 if (found) {
1862 // skip directory names
1863 const char *p1, *p2;
1864 p1 = buf;
1865 size_t len = strlen(os::file_separator());
1866 while ((p2 = strstr(p1, os::file_separator())) != NULL) p1 = p2 + len;
1867 jio_snprintf(buf, buflen, "%s+0x%x", p1, offset);
1868 } else {
1869 jio_snprintf(buf, buflen, PTR_FORMAT, handler);
1870 }
1871 return buf;
1872 }
1873
1874 static void print_signal_handler(outputStream* st, int sig,
1875 char* buf, size_t buflen) {
1876 struct sigaction sa;
1877
1878 sigaction(sig, NULL, &sa);
1879
1880 st->print("%s: ", os::exception_name(sig, buf, buflen));
1881
1882 address handler = (sa.sa_flags & SA_SIGINFO)
1883 ? CAST_FROM_FN_PTR(address, sa.sa_sigaction)
1884 : CAST_FROM_FN_PTR(address, sa.sa_handler);
1885
1886 if (handler == CAST_FROM_FN_PTR(address, SIG_DFL)) {
1887 st->print("SIG_DFL");
1888 } else if (handler == CAST_FROM_FN_PTR(address, SIG_IGN)) {
1889 st->print("SIG_IGN");
1890 } else {
1891 st->print("[%s]", get_signal_handler_name(handler, buf, buflen));
1892 }
1893
3666 //
3667 // This routine may recognize any of the following kinds of signals:
3668 // SIGBUS, SIGSEGV, SIGILL, SIGFPE, BREAK_SIGNAL, SIGPIPE, SIGXFSZ,
3669 // ASYNC_SIGNAL.
3670 // It should be consulted by handlers for any of those signals.
3671 //
3672 // The caller of this routine must pass in the three arguments supplied
3673 // to the function referred to in the "sa_sigaction" (not the "sa_handler")
3674 // field of the structure passed to sigaction(). This routine assumes that
3675 // the sa_flags field passed to sigaction() includes SA_SIGINFO and SA_RESTART.
3676 //
3677 // Note that the VM will print warnings if it detects conflicting signal
3678 // handlers, unless invoked with the option "-XX:+AllowUserSignalHandlers".
3679 //
3680 extern "C" JNIEXPORT int JVM_handle_solaris_signal(int signo,
3681 siginfo_t* siginfo,
3682 void* ucontext,
3683 int abort_if_unrecognized);
3684
3685
3686 void signalHandler(int sig, siginfo_t* info, void* ucVoid) {
3687 int orig_errno = errno; // Preserve errno value over signal handler.
3688 JVM_handle_solaris_signal(sig, info, ucVoid, true);
3689 errno = orig_errno;
3690 }
3691
3692 // This boolean allows users to forward their own non-matching signals
3693 // to JVM_handle_solaris_signal, harmlessly.
3694 bool os::Solaris::signal_handlers_are_installed = false;
3695
3696 // For signal-chaining
3697 bool os::Solaris::libjsig_is_loaded = false;
3698 typedef struct sigaction *(*get_signal_t)(int);
3699 get_signal_t os::Solaris::get_signal_action = NULL;
3700
3701 struct sigaction* os::Solaris::get_chained_signal_action(int sig) {
3702 struct sigaction *actp = NULL;
3703
3704 if ((libjsig_is_loaded) && (sig <= Maxsignum)) {
3705 // Retrieve the old signal handler from libjsig
3706 actp = (*get_signal_action)(sig);
4232 if (!Solaris::liblgrp_init()) {
4233 UseNUMA = false;
4234 } else {
4235 size_t lgrp_limit = os::numa_get_groups_num();
4236 int *lgrp_ids = NEW_C_HEAP_ARRAY(int, lgrp_limit, mtInternal);
4237 size_t lgrp_num = os::numa_get_leaf_groups(lgrp_ids, lgrp_limit);
4238 FREE_C_HEAP_ARRAY(int, lgrp_ids);
4239 if (lgrp_num < 2) {
4240 // There's only one locality group, disable NUMA.
4241 UseNUMA = false;
4242 }
4243 }
4244 if (!UseNUMA && ForceNUMA) {
4245 UseNUMA = true;
4246 }
4247 }
4248
4249 Solaris::signal_sets_init();
4250 Solaris::init_signal_mem();
4251 Solaris::install_signal_handlers();
4252
4253 // initialize synchronization primitives to use either thread or
4254 // lwp synchronization (controlled by UseLWPSynchronization)
4255 Solaris::synchronization_init();
4256
4257 if (MaxFDLimit) {
4258 // set the number of file descriptors to max. print out error
4259 // if getrlimit/setrlimit fails but continue regardless.
4260 struct rlimit nbr_files;
4261 int status = getrlimit(RLIMIT_NOFILE, &nbr_files);
4262 if (status != 0) {
4263 log_info(os)("os::init_2 getrlimit failed: %s", os::strerror(errno));
4264 } else {
4265 nbr_files.rlim_cur = nbr_files.rlim_max;
4266 status = setrlimit(RLIMIT_NOFILE, &nbr_files);
4267 if (status != 0) {
4268 log_info(os)("os::init_2 setrlimit failed: %s", os::strerror(errno));
4269 }
4270 }
4271 }
|
1854 }
1855
1856
1857 static const char* get_signal_handler_name(address handler,
1858 char* buf, int buflen) {
1859 int offset;
1860 bool found = os::dll_address_to_library_name(handler, buf, buflen, &offset);
1861 if (found) {
1862 // skip directory names
1863 const char *p1, *p2;
1864 p1 = buf;
1865 size_t len = strlen(os::file_separator());
1866 while ((p2 = strstr(p1, os::file_separator())) != NULL) p1 = p2 + len;
1867 jio_snprintf(buf, buflen, "%s+0x%x", p1, offset);
1868 } else {
1869 jio_snprintf(buf, buflen, PTR_FORMAT, handler);
1870 }
1871 return buf;
1872 }
1873
1874 void signalHandler(int sig, siginfo_t* info, void* ucVoid);
1875
1876 static void print_signal_handler(outputStream* st, int sig,
1877 char* buf, size_t buflen) {
1878 struct sigaction sa;
1879
1880 sigaction(sig, NULL, &sa);
1881
1882 st->print("%s: ", os::exception_name(sig, buf, buflen));
1883
1884 address handler = (sa.sa_flags & SA_SIGINFO)
1885 ? CAST_FROM_FN_PTR(address, sa.sa_sigaction)
1886 : CAST_FROM_FN_PTR(address, sa.sa_handler);
1887
1888 if (handler == CAST_FROM_FN_PTR(address, SIG_DFL)) {
1889 st->print("SIG_DFL");
1890 } else if (handler == CAST_FROM_FN_PTR(address, SIG_IGN)) {
1891 st->print("SIG_IGN");
1892 } else {
1893 st->print("[%s]", get_signal_handler_name(handler, buf, buflen));
1894 }
1895
3668 //
3669 // This routine may recognize any of the following kinds of signals:
3670 // SIGBUS, SIGSEGV, SIGILL, SIGFPE, BREAK_SIGNAL, SIGPIPE, SIGXFSZ,
3671 // ASYNC_SIGNAL.
3672 // It should be consulted by handlers for any of those signals.
3673 //
3674 // The caller of this routine must pass in the three arguments supplied
3675 // to the function referred to in the "sa_sigaction" (not the "sa_handler")
3676 // field of the structure passed to sigaction(). This routine assumes that
3677 // the sa_flags field passed to sigaction() includes SA_SIGINFO and SA_RESTART.
3678 //
3679 // Note that the VM will print warnings if it detects conflicting signal
3680 // handlers, unless invoked with the option "-XX:+AllowUserSignalHandlers".
3681 //
3682 extern "C" JNIEXPORT int JVM_handle_solaris_signal(int signo,
3683 siginfo_t* siginfo,
3684 void* ucontext,
3685 int abort_if_unrecognized);
3686
3687
3688 static void signalHandler(int sig, siginfo_t* info, void* ucVoid) {
3689 int orig_errno = errno; // Preserve errno value over signal handler.
3690 JVM_handle_solaris_signal(sig, info, ucVoid, true);
3691 errno = orig_errno;
3692 }
3693
3694 // This boolean allows users to forward their own non-matching signals
3695 // to JVM_handle_solaris_signal, harmlessly.
3696 bool os::Solaris::signal_handlers_are_installed = false;
3697
3698 // For signal-chaining
3699 bool os::Solaris::libjsig_is_loaded = false;
3700 typedef struct sigaction *(*get_signal_t)(int);
3701 get_signal_t os::Solaris::get_signal_action = NULL;
3702
3703 struct sigaction* os::Solaris::get_chained_signal_action(int sig) {
3704 struct sigaction *actp = NULL;
3705
3706 if ((libjsig_is_loaded) && (sig <= Maxsignum)) {
3707 // Retrieve the old signal handler from libjsig
3708 actp = (*get_signal_action)(sig);
4234 if (!Solaris::liblgrp_init()) {
4235 UseNUMA = false;
4236 } else {
4237 size_t lgrp_limit = os::numa_get_groups_num();
4238 int *lgrp_ids = NEW_C_HEAP_ARRAY(int, lgrp_limit, mtInternal);
4239 size_t lgrp_num = os::numa_get_leaf_groups(lgrp_ids, lgrp_limit);
4240 FREE_C_HEAP_ARRAY(int, lgrp_ids);
4241 if (lgrp_num < 2) {
4242 // There's only one locality group, disable NUMA.
4243 UseNUMA = false;
4244 }
4245 }
4246 if (!UseNUMA && ForceNUMA) {
4247 UseNUMA = true;
4248 }
4249 }
4250
4251 Solaris::signal_sets_init();
4252 Solaris::init_signal_mem();
4253 Solaris::install_signal_handlers();
4254 // Initialize data for jdk.internal.misc.Signal
4255 if (!ReduceSignalUsage) {
4256 signal_init_pd();
4257 }
4258
4259 // initialize synchronization primitives to use either thread or
4260 // lwp synchronization (controlled by UseLWPSynchronization)
4261 Solaris::synchronization_init();
4262
4263 if (MaxFDLimit) {
4264 // set the number of file descriptors to max. print out error
4265 // if getrlimit/setrlimit fails but continue regardless.
4266 struct rlimit nbr_files;
4267 int status = getrlimit(RLIMIT_NOFILE, &nbr_files);
4268 if (status != 0) {
4269 log_info(os)("os::init_2 getrlimit failed: %s", os::strerror(errno));
4270 } else {
4271 nbr_files.rlim_cur = nbr_files.rlim_max;
4272 status = setrlimit(RLIMIT_NOFILE, &nbr_files);
4273 if (status != 0) {
4274 log_info(os)("os::init_2 setrlimit failed: %s", os::strerror(errno));
4275 }
4276 }
4277 }
|