47
47
// signal handling (except suspend/resume)
48
48
// suspend/resume
49
49
50
+ // Glibc on Linux uses the SA_RESTORER flag to indicate
51
+ // the use of a "signal trampoline". We have no interest
52
+ // in this flag and need to ignore it when checking our
53
+ // own flag settings.
54
+ // Note: SA_RESTORER is not exposed through signal.h so we
55
+ // have to hardwire its 0x04000000 value in the mask.
56
+ LINUX_ONLY (const int SA_RESTORER_FLAG_MASK = ~0x04000000 ;)
57
+
50
58
// Todo: provide a os::get_max_process_id() or similar. Number of processes
51
59
// may have been configured, can be read more accurately from proc fs etc.
52
60
#ifndef MAX_PID
@@ -657,9 +665,19 @@ static const char* describe_sa_flags(int flags, char* buffer, size_t size) {
657
665
658
666
strncpy (buffer, " none" , size);
659
667
668
+ const unsigned int unknown_flag = ~(SA_NOCLDSTOP |
669
+ SA_ONSTACK |
670
+ SA_NOCLDSTOP |
671
+ SA_RESTART |
672
+ SA_SIGINFO |
673
+ SA_NOCLDWAIT |
674
+ SA_NODEFER
675
+ AIX_ONLY (| SA_OLDSTYLE)
676
+ );
677
+
660
678
const struct {
661
679
// NB: i is an unsigned int here because SA_RESETHAND is on some
662
- // systems 0x80000000, which is implicitly unsigned. Assignining
680
+ // systems 0x80000000, which is implicitly unsigned. Assigning
663
681
// it to an int field would be an overflow in unsigned-to-signed
664
682
// conversion.
665
683
unsigned int i;
@@ -675,10 +693,10 @@ static const char* describe_sa_flags(int flags, char* buffer, size_t size) {
675
693
#if defined(AIX)
676
694
{ SA_OLDSTYLE, " SA_OLDSTYLE" },
677
695
#endif
678
- { 0 , NULL }
696
+ { unknown_flag, " NOT USED " }
679
697
};
680
698
681
- for (idx = 0 ; flaginfo[idx].s && remaining > 1 ; idx++) {
699
+ for (idx = 0 ; flaginfo[idx].i != unknown_flag && remaining > 1 ; idx++) {
682
700
if (flags & flaginfo[idx].i ) {
683
701
if (first) {
684
702
jio_snprintf (p, remaining, " %s" , flaginfo[idx].s );
@@ -691,6 +709,10 @@ static const char* describe_sa_flags(int flags, char* buffer, size_t size) {
691
709
remaining -= len;
692
710
}
693
711
}
712
+ unsigned int unknowns = flags & unknown_flag;
713
+ if (unknowns != 0 ) {
714
+ jio_snprintf (p, remaining, " |Unknown_flags:%x" , unknowns);
715
+ }
694
716
695
717
buffer[size - 1 ] = ' \0 ' ;
696
718
@@ -734,6 +756,9 @@ static void check_signal_handler(int sig) {
734
756
735
757
os_sigaction (sig, (struct sigaction *)NULL , &act);
736
758
759
+ // See comment for SA_RESTORER_FLAG_MASK
760
+ LINUX_ONLY (act.sa_flags &= SA_RESTORER_FLAG_MASK;)
761
+
737
762
address thisHandler = (act.sa_flags & SA_SIGINFO)
738
763
? CAST_FROM_FN_PTR (address, act.sa_sigaction )
739
764
: CAST_FROM_FN_PTR (address, act.sa_handler );
@@ -1310,6 +1335,9 @@ void PosixSignals::print_signal_handler(outputStream* st, int sig,
1310
1335
struct sigaction sa;
1311
1336
sigaction (sig, NULL , &sa);
1312
1337
1338
+ // See comment for SA_RESTORER_FLAG_MASK
1339
+ LINUX_ONLY (sa.sa_flags &= SA_RESTORER_FLAG_MASK;)
1340
+
1313
1341
st->print (" %s: " , os::exception_name (sig, buf, buflen));
1314
1342
1315
1343
address handler = (sa.sa_flags & SA_SIGINFO)
@@ -1331,7 +1359,8 @@ void PosixSignals::print_signal_handler(outputStream* st, int sig,
1331
1359
// May be, handler was resetted by VMError?
1332
1360
if (rh != NULL ) {
1333
1361
handler = rh;
1334
- sa.sa_flags = VMError::get_resetted_sigflags (sig);
1362
+ // See comment for SA_RESTORER_FLAG_MASK
1363
+ sa.sa_flags = VMError::get_resetted_sigflags (sig) LINUX_ONLY (& SA_RESTORER_FLAG_MASK);
1335
1364
}
1336
1365
1337
1366
// Print textual representation of sa_flags.
0 commit comments