- Timestamp:
- Feb 4, 2020, 11:29:22 AM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 52142c2, 9f575ea, bdfc032
- Parents:
- 09f357ec (diff), e56eb455 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- libcfa/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/defs.hfa
r09f357ec r4f7b418 10 10 // Created On : Thu Nov 9 13:24:10 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 8 16:22:41 201813 // Update Count : 812 // Last Modified On : Tue Jan 28 22:38:27 2020 13 // Update Count : 9 14 14 // 15 15 … … 34 34 35 35 #ifdef __cforall 36 void abort ( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )); 36 void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )); 37 void abort( bool signalAbort, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )); 37 38 extern "C" { 38 39 #endif -
libcfa/src/bits/signal.hfa
r09f357ec r4f7b418 40 40 sigaddset( &act.sa_mask, SIGALRM ); // disabled during signal handler 41 41 sigaddset( &act.sa_mask, SIGUSR1 ); 42 sigaddset( &act.sa_mask, SIGSEGV ); 43 sigaddset( &act.sa_mask, SIGBUS ); 44 sigaddset( &act.sa_mask, SIGILL ); 45 sigaddset( &act.sa_mask, SIGFPE ); 46 sigaddset( &act.sa_mask, SIGHUP ); // revert to default on second delivery 47 sigaddset( &act.sa_mask, SIGTERM ); 48 sigaddset( &act.sa_mask, SIGINT ); 42 49 act.sa_flags = flags; 43 50 44 if ( sigaction( sig, &act, NULL) == -1 ) {51 if ( sigaction( sig, &act, 0p ) == -1 ) { 45 52 __cfaabi_dbg_print_buffer_decl( 46 53 " __cfaabi_sigaction( sig:%d, handler:%p, flags:%d ), problem installing signal handler, error(%d) %s.\n", … … 48 55 ); 49 56 _exit( EXIT_FAILURE ); 50 } 57 } // if 51 58 } 52 53 // Sigaction wrapper : restore default handler54 static void __cfaabi_sigdefault( int sig ) {55 struct sigaction act;56 57 act.sa_handler = SIG_DFL;58 act.sa_flags = 0;59 sigemptyset( &act.sa_mask );60 61 if ( sigaction( sig, &act, NULL ) == -1 ) {62 __cfaabi_dbg_print_buffer_decl(63 " __cfaabi_sigdefault( sig:%d ), problem reseting signal handler, error(%d) %s.\n",64 sig, errno, strerror( errno )65 );66 _exit( EXIT_FAILURE );67 }68 } -
libcfa/src/concurrency/kernel.cfa
r09f357ec r4f7b418 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Dec 5 16:25:52 201913 // Update Count : 5 212 // Last Modified On : Thu Jan 30 22:55:50 2020 13 // Update Count : 56 14 14 // 15 15 … … 844 844 sigemptyset( &mask ); 845 845 sigaddset( &mask, SIGALRM ); // block SIGALRM signals 846 sigsuspend( &mask ); // block the processor to prevent further damage during abort 847 _exit( EXIT_FAILURE ); // if processor unblocks before it is killed, terminate it 846 sigaddset( &mask, SIGUSR1 ); // block SIGALRM signals 847 sigsuspend( &mask ); // block the processor to prevent further damage during abort 848 _exit( EXIT_FAILURE ); // if processor unblocks before it is killed, terminate it 848 849 } 849 850 else { -
libcfa/src/interpose.cfa
r09f357ec r4f7b418 10 10 // Created On : Wed Mar 29 16:10:31 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 13:45:21 201913 // Update Count : 1 2112 // Last Modified On : Thu Jan 30 17:47:32 2020 13 // Update Count : 156 14 14 // 15 15 … … 95 95 void __cfaabi_interpose_startup(void) __attribute__(( constructor( STARTUP_PRIORITY_CORE ) )); 96 96 void __cfaabi_interpose_startup( void ) { 97 const char *version = NULL;97 const char *version = 0p; 98 98 99 99 preload_libgcc(); … … 105 105 #pragma GCC diagnostic pop 106 106 107 // As a precaution (and necessity), errors that result in termination are delivered on a separate stack because 108 // task stacks might be very small (4K) and the signal delivery corrupts memory to the point that a clean 109 // shutdown is impossible. Also, when a stack overflow encounters the non-accessible sentinel page (debug only) 110 // and generates a segment fault, the signal cannot be delivered on the sentinel page. Finally, calls to abort 111 // print a stack trace that uses substantial stack space. 112 113 #define MINSTKSZ SIGSTKSZ * 8 114 static char stack[MINSTKSZ] __attribute__(( aligned (16) )); 115 static stack_t ss; 116 117 ss.ss_sp = stack; 118 ss.ss_size = MINSTKSZ; 119 ss.ss_flags = 0; 120 if ( sigaltstack( &ss, 0p ) == -1 ) { 121 abort( "__cfaabi_interpose_startup : internal error, sigaltstack error(%d) %s.", errno, strerror( errno ) ); 122 } // if 123 107 124 // Failure handler 108 __cfaabi_sigaction( SIGSEGV, sigHandler_segv , SA_SIGINFO ); 109 __cfaabi_sigaction( SIGBUS , sigHandler_segv , SA_SIGINFO ); 110 __cfaabi_sigaction( SIGILL , sigHandler_ill , SA_SIGINFO ); 111 __cfaabi_sigaction( SIGFPE , sigHandler_fpe , SA_SIGINFO ); 112 __cfaabi_sigaction( SIGABRT, sigHandler_abrt, SA_SIGINFO | SA_RESETHAND); 113 __cfaabi_sigaction( SIGTERM, sigHandler_term , SA_SIGINFO ); 114 __cfaabi_sigaction( SIGINT , sigHandler_term , SA_SIGINFO ); 125 __cfaabi_sigaction( SIGSEGV, sigHandler_segv, SA_SIGINFO | SA_ONSTACK ); 126 __cfaabi_sigaction( SIGBUS , sigHandler_segv, SA_SIGINFO | SA_ONSTACK ); 127 __cfaabi_sigaction( SIGILL , sigHandler_ill , SA_SIGINFO | SA_ONSTACK ); 128 __cfaabi_sigaction( SIGFPE , sigHandler_fpe , SA_SIGINFO | SA_ONSTACK ); 129 __cfaabi_sigaction( SIGTERM, sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND ); // one shot handler, return to default 130 __cfaabi_sigaction( SIGINT , sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND ); 131 __cfaabi_sigaction( SIGABRT, sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND ); 132 __cfaabi_sigaction( SIGHUP , sigHandler_term, SA_SIGINFO | SA_ONSTACK | SA_RESETHAND ); // terminal hangup 115 133 } 116 134 } … … 123 141 void exit( int status, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )); 124 142 void abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )); 143 void abort( bool signalAbort, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )); 125 144 126 145 extern "C" { 127 146 void abort( void ) __attribute__(( __nothrow__, __leaf__, __noreturn__ )) { 128 abort( NULL );147 abort( false, NULL ); // FIX ME: 0p does not work 129 148 } 130 149 … … 132 151 va_list argp; 133 152 va_start( argp, fmt ); 134 abort( f mt, argp );153 abort( false, fmt, argp ); 135 154 va_end( argp ); 136 155 } … … 141 160 } 142 161 143 void * kernel_abort ( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return NULL; } 144 void kernel_abort_msg( void * data, char * buffer, int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {} 162 void * kernel_abort( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 0p; } 163 void kernel_abort_msg( void * data, char * buffer, int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {} 164 // See concurrency/kernel.cfa for strong definition used in multi-processor mode. 145 165 int kernel_abort_lastframe( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 4; } 146 166 147 167 enum { abort_text_size = 1024 }; 148 168 static char abort_text[ abort_text_size ]; 149 static int abort_lastframe; 150 151 void exit( int status, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )) { 152 va_list args; 153 va_start( args, fmt ); 154 vfprintf( stderr, fmt, args ); 155 va_end( args ); 156 __cabi_libc.exit( status ); 157 } 158 159 void abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )) { 160 void * kernel_data = kernel_abort(); // must be done here to lock down kernel 161 int len; 162 163 abort_lastframe = kernel_abort_lastframe(); 164 len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid) 165 __cfaabi_dbg_write( abort_text, len ); 166 167 if ( fmt ) { 168 va_list args; 169 va_start( args, fmt ); 170 171 len = vsnprintf( abort_text, abort_text_size, fmt, args ); 172 va_end( args ); 173 __cfaabi_dbg_write( abort_text, len ); 174 175 if ( fmt[strlen( fmt ) - 1] != '\n' ) { // add optional newline if missing at the end of the format text 176 __cfaabi_dbg_write( "\n", 1 ); 177 } 178 } 179 180 kernel_abort_msg( kernel_data, abort_text, abort_text_size ); 181 __cabi_libc.abort(); 182 } 183 184 static void __cfaabi_backtrace() { 169 170 static void __cfaabi_backtrace( int start ) { 185 171 enum { 186 172 Frames = 50, // maximum number of stack frames 187 Start = 8, // skip first N stack frames188 173 }; 174 int last = kernel_abort_lastframe(); // skip last N stack frames 189 175 190 176 void * array[Frames]; … … 192 178 char ** messages = backtrace_symbols( array, size ); 193 179 194 // find executable name 195 *index( messages[0], '(' ) = '\0'; 180 *index( messages[0], '(' ) = '\0'; // find executable name 196 181 __cfaabi_bits_print_nolock( STDERR_FILENO, "Stack back trace for: %s\n", messages[0]); 197 182 198 for ( int i = Start; i < size - abort_lastframe&& messages != 0p; i += 1 ) {183 for ( unsigned int i = start; i < size - last && messages != 0p; i += 1 ) { 199 184 char * name = 0p, * offset_begin = 0p, * offset_end = 0p; 200 185 201 for ( char * p = messages[i]; *p; ++p ) { 186 for ( char * p = messages[i]; *p; ++p ) { // find parantheses and +offset 202 187 //__cfaabi_bits_print_nolock( "X %s\n", p); 203 // find parantheses and +offset204 188 if ( *p == '(' ) { 205 189 name = p; … … 212 196 } 213 197 214 // if line contains symbol print it215 int frameNo = i - Start;198 // if line contains symbol, print it 199 int frameNo = i - start; 216 200 if ( name && offset_begin && offset_end && name < offset_begin ) { 217 // delimit strings 218 *name++ = '\0'; 201 *name++ = '\0'; // delimit strings 219 202 *offset_begin++ = '\0'; 220 203 *offset_end++ = '\0'; … … 228 211 } 229 212 213 void exit( int status, const char fmt[], ... ) { 214 va_list args; 215 va_start( args, fmt ); 216 vfprintf( stderr, fmt, args ); 217 va_end( args ); 218 __cabi_libc.exit( status ); 219 } 220 221 void abort( bool signalAbort, const char fmt[], ... ) { 222 void * kernel_data = kernel_abort(); // must be done here to lock down kernel 223 int len; 224 225 signal( SIGABRT, SIG_DFL ); // prevent final "real" abort from recursing to handler 226 227 len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid) 228 __cfaabi_bits_write( STDERR_FILENO, abort_text, len ); 229 230 if ( fmt ) { 231 va_list args; 232 va_start( args, fmt ); 233 234 len = vsnprintf( abort_text, abort_text_size, fmt, args ); 235 va_end( args ); 236 __cfaabi_bits_write( STDERR_FILENO, abort_text, len ); 237 238 if ( fmt[strlen( fmt ) - 1] != '\n' ) { // add optional newline if missing at the end of the format text 239 __cfaabi_dbg_write( "\n", 1 ); 240 } 241 } 242 243 kernel_abort_msg( kernel_data, abort_text, abort_text_size ); 244 __cfaabi_backtrace( signalAbort ? 4 : 3 ); 245 246 __cabi_libc.abort(); // print stack trace in handler 247 } 248 249 void abort( const char fmt[], ... ) { 250 va_list args; 251 va_start( args, fmt ); 252 abort( false, fmt, args ); 253 va_end( args ); 254 } 255 230 256 void sigHandler_segv( __CFA_SIGPARMS__ ) { 231 if ( sfp->si_addr == NULL) {232 abort( "Null pointer (0p) dereference.\n" );257 if ( sfp->si_addr == 0p ) { 258 abort( true, "Null pointer (0p) dereference.\n" ); 233 259 } else { 234 abort( "%s at memory location %p.\n"260 abort( true, "%s at memory location %p.\n" 235 261 "Possible cause is reading outside the address space or writing to a protected area within the address space with an invalid pointer or subscript.\n", 236 262 (sig == SIGSEGV ? "Segment fault" : "Bus error"), sfp->si_addr ); … … 239 265 240 266 void sigHandler_ill( __CFA_SIGPARMS__ ) { 241 abort( "Executing illegal instruction at location %p.\n"267 abort( true, "Executing illegal instruction at location %p.\n" 242 268 "Possible cause is stack corruption.\n", 243 269 sfp->si_addr ); … … 255 281 default: msg = "unknown"; 256 282 } // choose 257 abort( "Computation error %s at location %p.\n", msg, sfp->si_addr ); 258 } 259 260 void sigHandler_abrt( __CFA_SIGPARMS__ ) { 261 __cfaabi_backtrace(); 262 263 // reset default signal handler 264 __cfaabi_sigdefault( SIGABRT ); 265 266 raise( SIGABRT ); 283 abort( true, "Computation error %s at location %p.\n", msg, sfp->si_addr ); 267 284 } 268 285 269 286 void sigHandler_term( __CFA_SIGPARMS__ ) { 270 abort( "Application stopped by %s signal.", sig == SIGINT ? "an interrupt (SIGINT)" : "a terminate (SIGTERM)");287 abort( true, "Application interrupted by signal: %s.\n", strsignal( sig ) ); 271 288 } 272 289 -
libcfa/src/stdhdr/bfdlink.h
r09f357ec r4f7b418 10 10 // Created On : Tue Jul 18 07:26:04 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S un Jul 22 13:49:30 201813 // Update Count : 412 // Last Modified On : Sat Feb 1 07:15:29 2020 13 // Update Count : 5 14 14 // 15 15 16 16 // include file uses the CFA keyword "with". 17 17 #if ! defined( with ) // nesting ? 18 #define with ` with`// make keyword an identifier18 #define with ``with`` // make keyword an identifier 19 19 #define __CFA_BFDLINK_H__ 20 20 #endif -
libcfa/src/stdhdr/hwloc.h
r09f357ec r4f7b418 10 10 // Created On : Tue Jul 18 07:45:00 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S un Jul 22 13:49:58 201813 // Update Count : 412 // Last Modified On : Sat Feb 1 07:15:39 2020 13 // Update Count : 5 14 14 // 15 15 16 16 // include file uses the CFA keyword "thread". 17 17 #if ! defined( thread ) // nesting ? 18 #define thread ` thread`// make keyword an identifier18 #define thread ``thread`` // make keyword an identifier 19 19 #define __CFA_HWLOC_H__ 20 20 #endif -
libcfa/src/stdhdr/krb5.h
r09f357ec r4f7b418 10 10 // Created On : Tue Jul 18 07:55:44 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S un Jul 22 13:50:24 201813 // Update Count : 412 // Last Modified On : Sat Feb 1 07:15:47 2020 13 // Update Count : 5 14 14 // 15 15 16 16 // include file uses the CFA keyword "enable". 17 17 #if ! defined( enable ) // nesting ? 18 #define enable ` enable`// make keyword an identifier18 #define enable ``enable`` // make keyword an identifier 19 19 #define __CFA_KRB5_H__ 20 20 #endif -
libcfa/src/stdhdr/math.h
r09f357ec r4f7b418 10 10 // Created On : Mon Jul 4 23:25:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 22 18:16:07 201813 // Update Count : 1 312 // Last Modified On : Sat Feb 1 07:15:58 2020 13 // Update Count : 14 14 14 // 15 15 16 16 extern "C" { 17 17 #if ! defined( exception ) // nesting ? 18 #define exception ` exception` // make keyword an identifier18 #define exception ``exception`` // make keyword an identifier 19 19 #define __CFA_MATH_H__ 20 20 #endif -
libcfa/src/stdhdr/sys/ucontext.h
r09f357ec r4f7b418 10 10 // Created On : Thu Feb 8 23:48:16 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 8 23:50:44 201813 // Update Count : 412 // Last Modified On : Sat Feb 1 07:16:05 2020 13 // Update Count : 5 14 14 // 15 15 16 16 #if ! defined( ftype ) // nesting ? 17 #define ftype ` ftype` // make keyword an identifier17 #define ftype ``ftype`` // make keyword an identifier 18 18 #define __CFA_UCONTEXT_H__ 19 19 #endif
Note: See TracChangeset
for help on using the changeset viewer.