@@ -69,30 +69,58 @@ fn test_crash_tracking_bin_fork() {
6969
7070#[ test]  
7171#[ cfg_attr( miri,  ignore) ]  
72- fn  test_crash_tracking_bin_abort ( )  { 
72+ fn  test_crash_tracking_bin_kill_sigabrt ( )  { 
7373    // For now, do the base test (donothing).  For future we should probably also test chaining. 
74-     test_crash_tracking_bin ( BuildProfile :: Release ,  "donothing" ,  "sigabrt " ) ; 
74+     test_crash_tracking_bin ( BuildProfile :: Release ,  "donothing" ,  "kill_sigabrt " ) ; 
7575} 
7676
7777#[ test]  
7878#[ cfg_attr( miri,  ignore) ]  
79- fn  test_crash_tracking_bin_sigill ( )  { 
79+ fn  test_crash_tracking_bin_kill_sigill ( )  { 
8080    // For now, do the base test (donothing).  For future we should probably also test chaining. 
81-     test_crash_tracking_bin ( BuildProfile :: Release ,  "donothing" ,  "sigill " ) ; 
81+     test_crash_tracking_bin ( BuildProfile :: Release ,  "donothing" ,  "kill_sigill " ) ; 
8282} 
8383
8484#[ test]  
8585#[ cfg_attr( miri,  ignore) ]  
86- fn  test_crash_tracking_bin_sigbus ( )  { 
86+ fn  test_crash_tracking_bin_kill_sigbus ( )  { 
8787    // For now, do the base test (donothing).  For future we should probably also test chaining. 
88-     test_crash_tracking_bin ( BuildProfile :: Release ,  "donothing" ,  "sigbus " ) ; 
88+     test_crash_tracking_bin ( BuildProfile :: Release ,  "donothing" ,  "kill_sigbus " ) ; 
8989} 
9090
9191#[ test]  
9292#[ cfg_attr( miri,  ignore) ]  
93- fn  test_crash_tracking_bin_sigsegv ( )  { 
93+ fn  test_crash_tracking_bin_kill_sigsegv ( )  { 
9494    // For now, do the base test (donothing).  For future we should probably also test chaining. 
95-     test_crash_tracking_bin ( BuildProfile :: Release ,  "donothing" ,  "sigsegv" ) ; 
95+     test_crash_tracking_bin ( BuildProfile :: Release ,  "donothing" ,  "kill_sigsegv" ) ; 
96+ } 
97+ 
98+ #[ test]  
99+ #[ cfg_attr( miri,  ignore) ]  
100+ fn  test_crash_tracking_bin_raise_sigabrt ( )  { 
101+     // For now, do the base test (donothing).  For future we should probably also test chaining. 
102+     test_crash_tracking_bin ( BuildProfile :: Release ,  "donothing" ,  "raise_sigabrt" ) ; 
103+ } 
104+ 
105+ #[ test]  
106+ #[ cfg_attr( miri,  ignore) ]  
107+ fn  test_crash_tracking_bin_raise_sigill ( )  { 
108+     // For now, do the base test (donothing).  For future we should probably also test chaining. 
109+     test_crash_tracking_bin ( BuildProfile :: Release ,  "donothing" ,  "raise_sigill" ) ; 
110+ } 
111+ 
112+ #[ test]  
113+ #[ cfg_attr( miri,  ignore) ]  
114+ fn  test_crash_tracking_bin_raise_sigbus ( )  { 
115+     // For now, do the base test (donothing).  For future we should probably also test chaining. 
116+     test_crash_tracking_bin ( BuildProfile :: Release ,  "donothing" ,  "raise_sigbus" ) ; 
117+ } 
118+ 
119+ #[ test]  
120+ #[ cfg_attr( miri,  ignore) ]  
121+ fn  test_crash_tracking_bin_raise_sigsegv ( )  { 
122+     // For now, do the base test (donothing).  For future we should probably also test chaining. 
123+     test_crash_tracking_bin ( BuildProfile :: Release ,  "donothing" ,  "raise_sigsegv" ) ; 
96124} 
97125
98126fn  test_crash_tracking_bin ( 
@@ -122,8 +150,12 @@ fn test_crash_tracking_bin(
122150    // Not sure why sigill behaves differently?? 
123151    // TODO: figure that out. 
124152    match  crash_typ { 
125-         "null_deref"  | "sigabrt"  | "sigill"  => assert ! ( !exit_status. success( ) ) , 
126-         "sigbus"  | "sigsegv"  => ( ) , 
153+         "kill_sigabrt"  | "kill_sigill"  | "null_deref"  | "raise_sigabrt"  | "raise_sigill"  => { 
154+             assert ! ( !exit_status. success( ) ) 
155+         } 
156+         "kill_sigbus"  | "kill_sigsegv"  | "raise_sigbus"  | "raise_sigsegv"  => { 
157+             assert ! ( exit_status. success( ) ) 
158+         } 
127159        _ => unreachable ! ( "{crash_typ} shouldn't happen" ) , 
128160    } 
129161
@@ -186,22 +218,6 @@ fn test_crash_tracking_bin(
186218
187219fn  assert_siginfo_message ( sig_info :  & Value ,  crash_typ :  & str )  { 
188220    match  crash_typ { 
189-         "sigabrt"  => { 
190-             assert_eq ! ( sig_info[ "si_signo" ] ,  libc:: SIGABRT ) ; 
191-             assert_eq ! ( sig_info[ "si_signo_human_readable" ] ,  "SIGABRT" ) ; 
192-         } 
193-         "sigsegv"  => { 
194-             assert_eq ! ( sig_info[ "si_signo" ] ,  libc:: SIGSEGV ) ; 
195-             assert_eq ! ( sig_info[ "si_signo_human_readable" ] ,  "SIGSEGV" ) ; 
196-         } 
197-         "sigbus"  => { 
198-             assert_eq ! ( sig_info[ "si_signo" ] ,  libc:: SIGBUS ) ; 
199-             assert_eq ! ( sig_info[ "si_signo_human_readable" ] ,  "SIGBUS" ) ; 
200-         } 
201-         "sigill"  => { 
202-             assert_eq ! ( sig_info[ "si_signo" ] ,  libc:: SIGILL ) ; 
203-             assert_eq ! ( sig_info[ "si_signo_human_readable" ] ,  "SIGILL" ) ; 
204-         } 
205221        "null_deref"  =>
206222        // On every platform other than OSX ARM, the si_code is 1: SEGV_MAPERR 
207223        // On OSX ARM, its 2: SEGV_ACCERR 
@@ -219,6 +235,72 @@ fn assert_siginfo_message(sig_info: &Value, crash_typ: &str) {
219235            assert_eq ! ( sig_info[ "si_signo" ] ,  libc:: SIGSEGV ) ; 
220236            assert_eq ! ( sig_info[ "si_signo_human_readable" ] ,  "SIGSEGV" ) ; 
221237        } 
238+ 
239+         "kill_sigabrt"  => { 
240+             assert_eq ! ( sig_info[ "si_signo" ] ,  libc:: SIGABRT ) ; 
241+             assert_eq ! ( sig_info[ "si_signo_human_readable" ] ,  "SIGABRT" ) ; 
242+             // https://vorner.github.io/2021/01/03/dark-side-of-posix-apis.html 
243+             // OSX signal handling is the worst. 
244+             assert ! ( 
245+                 sig_info[ "si_code_human_readable" ]  == "UNKNOWN" 
246+                     || sig_info[ "si_code_human_readable" ]  == "SI_USER" , 
247+                 "{sig_info:?}" 
248+             ) ; 
249+         } 
250+         "kill_sigsegv"  => { 
251+             assert_eq ! ( sig_info[ "si_signo" ] ,  libc:: SIGSEGV ) ; 
252+             assert_eq ! ( sig_info[ "si_signo_human_readable" ] ,  "SIGSEGV" ) ; 
253+             // https://vorner.github.io/2021/01/03/dark-side-of-posix-apis.html 
254+             // OSX signal handling is the worst. 
255+             assert ! ( 
256+                 matches!( 
257+                     sig_info[ "si_code_human_readable" ] . as_str( ) . unwrap( ) , 
258+                     "UNKNOWN"  | "SI_USER"  | "SEGV_ACCERR" 
259+                 ) , 
260+                 "{sig_info:?}" 
261+             ) ; 
262+         } 
263+         "kill_sigbus"  => { 
264+             assert_eq ! ( sig_info[ "si_signo" ] ,  libc:: SIGBUS ) ; 
265+             assert_eq ! ( sig_info[ "si_signo_human_readable" ] ,  "SIGBUS" ) ; 
266+             // https://vorner.github.io/2021/01/03/dark-side-of-posix-apis.html 
267+             // OSX signal handling is the worst. 
268+             assert ! ( 
269+                 matches!( 
270+                     sig_info[ "si_code_human_readable" ] . as_str( ) . unwrap( ) , 
271+                     "UNKNOWN"  | "SI_USER"  | "BUS_ADRALN" 
272+                 ) , 
273+                 "{sig_info:?}" 
274+             ) ; 
275+ 
276+         } 
277+         "kill_sigill"  => { 
278+             assert_eq ! ( sig_info[ "si_signo" ] ,  libc:: SIGILL ) ; 
279+             assert_eq ! ( sig_info[ "si_signo_human_readable" ] ,  "SIGILL" ) ; 
280+             // https://vorner.github.io/2021/01/03/dark-side-of-posix-apis.html 
281+             // OSX signal handling is the worst. 
282+             assert ! ( 
283+                 sig_info[ "si_code_human_readable" ]  == "UNKNOWN" 
284+                     || sig_info[ "si_code_human_readable" ]  == "SI_USER" , 
285+                 "{sig_info:?}" 
286+             ) ; 
287+         } 
288+         "raise_sigabrt"  => { 
289+             assert_eq ! ( sig_info[ "si_signo" ] ,  libc:: SIGABRT ) ; 
290+             assert_eq ! ( sig_info[ "si_signo_human_readable" ] ,  "SIGABRT" ) ; 
291+         } 
292+         "raise_sigsegv"  => { 
293+             assert_eq ! ( sig_info[ "si_signo" ] ,  libc:: SIGSEGV ) ; 
294+             assert_eq ! ( sig_info[ "si_signo_human_readable" ] ,  "SIGSEGV" ) ; 
295+         } 
296+         "raise_sigbus"  => { 
297+             assert_eq ! ( sig_info[ "si_signo" ] ,  libc:: SIGBUS ) ; 
298+             assert_eq ! ( sig_info[ "si_signo_human_readable" ] ,  "SIGBUS" ) ; 
299+         } 
300+         "raise_sigill"  => { 
301+             assert_eq ! ( sig_info[ "si_signo" ] ,  libc:: SIGILL ) ; 
302+             assert_eq ! ( sig_info[ "si_signo_human_readable" ] ,  "SIGILL" ) ; 
303+         } 
222304        _ => panic ! ( "unexpected crash_typ {crash_typ}" ) , 
223305    } 
224306} 
@@ -260,12 +342,32 @@ fn assert_telemetry_message(crash_telemetry: &[u8], crash_typ: &str) {
260342        ] ) ; 
261343
262344    match  crash_typ { 
263-         "sigabrt"  => { 
345+         "null_deref"  => { 
346+             assert ! ( base_expected_tags. is_subset( & tags) ,  "{tags:?}" ) ; 
347+             assert ! ( tags. contains( "si_addr:0x0000000000000000" ) ,  "{tags:?}" ) ; 
348+             assert ! ( 
349+                 tags. contains( "si_code_human_readable:SEGV_ACCERR" ) 
350+                     || tags. contains( "si_code_human_readable:SEGV_MAPERR" ) , 
351+                 "{tags:?}" 
352+             ) ; 
353+             assert ! ( tags. contains( "si_signo_human_readable:SIGSEGV" ) ,  "{tags:?}" ) ; 
354+             assert ! ( tags. contains( "si_signo:11" ) ,  "{tags:?}" ) ; 
355+             assert ! ( 
356+                 tags. contains( "si_code:1" )  || tags. contains( "si_code:2" ) , 
357+                 "{tags:?}" 
358+             ) ; 
359+         } 
360+         "kill_sigabrt"  => { 
264361            assert ! ( base_expected_tags. is_subset( & tags) ,  "{tags:?}" ) ; 
265362            assert ! ( tags. contains( "si_signo_human_readable:SIGABRT" ) ,  "{tags:?}" ) ; 
266363            assert ! ( tags. contains( "si_signo:6" ) ,  "{tags:?}" ) ; 
267364        } 
268-         "sigbus"  => { 
365+         "kill_sigill"  => { 
366+             assert ! ( base_expected_tags. is_subset( & tags) ,  "{tags:?}" ) ; 
367+             assert ! ( tags. contains( "si_signo_human_readable:SIGILL" ) ,  "{tags:?}" ) ; 
368+             assert ! ( tags. contains( "si_signo:4" ) ,  "{tags:?}" ) ; 
369+         } 
370+         "kill_sigbus"  => { 
269371            assert ! ( base_expected_tags. is_subset( & tags) ,  "{tags:?}" ) ; 
270372            assert ! ( tags. contains( "si_signo_human_readable:SIGBUS" ) ,  "{tags:?}" ) ; 
271373            // SIGBUS can be 7 or 10, depending on the os. 
@@ -274,30 +376,34 @@ fn assert_telemetry_message(crash_telemetry: &[u8], crash_typ: &str) {
274376                "{tags:?}" 
275377            ) ; 
276378        } 
277-         "sigill"  => { 
278-             assert ! ( base_expected_tags. is_subset( & tags) ,  "{tags:?}" ) ; 
279-             assert ! ( tags. contains( "si_signo_human_readable:SIGILL" ) ,  "{tags:?}" ) ; 
280-             assert ! ( tags. contains( "si_signo:4" ) ,  "{tags:?}" ) ; 
281-         } 
282-         "sigsegv"  => { 
379+         "kill_sigsegv"  => { 
283380            assert ! ( base_expected_tags. is_subset( & tags) ,  "{tags:?}" ) ; 
284381            assert ! ( tags. contains( "si_signo_human_readable:SIGSEGV" ) ,  "{tags:?}" ) ; 
285382            assert ! ( tags. contains( "si_signo:11" ) ,  "{tags:?}" ) ; 
286383        } 
287-         "null_deref "  => { 
384+         "raise_sigabrt "  => { 
288385            assert ! ( base_expected_tags. is_subset( & tags) ,  "{tags:?}" ) ; 
289-             assert ! ( tags. contains( "si_addr:0x0000000000000000" ) ,  "{tags:?}" ) ; 
386+             assert ! ( tags. contains( "si_signo_human_readable:SIGABRT" ) ,  "{tags:?}" ) ; 
387+             assert ! ( tags. contains( "si_signo:6" ) ,  "{tags:?}" ) ; 
388+         } 
389+         "raise_sigill"  => { 
390+             assert ! ( base_expected_tags. is_subset( & tags) ,  "{tags:?}" ) ; 
391+             assert ! ( tags. contains( "si_signo_human_readable:SIGILL" ) ,  "{tags:?}" ) ; 
392+             assert ! ( tags. contains( "si_signo:4" ) ,  "{tags:?}" ) ; 
393+         } 
394+         "raise_sigbus"  => { 
395+             assert ! ( base_expected_tags. is_subset( & tags) ,  "{tags:?}" ) ; 
396+             assert ! ( tags. contains( "si_signo_human_readable:SIGBUS" ) ,  "{tags:?}" ) ; 
397+             // SIGBUS can be 7 or 10, depending on the os. 
290398            assert ! ( 
291-                 tags. contains( "si_code_human_readable:SEGV_ACCERR" ) 
292-                     || tags. contains( "si_code_human_readable:SEGV_MAPERR" ) , 
399+                 tags. contains( format!( "si_signo:{}" ,  libc:: SIGBUS ) . as_str( ) ) , 
293400                "{tags:?}" 
294401            ) ; 
402+         } 
403+         "raise_sigsegv"  => { 
404+             assert ! ( base_expected_tags. is_subset( & tags) ,  "{tags:?}" ) ; 
295405            assert ! ( tags. contains( "si_signo_human_readable:SIGSEGV" ) ,  "{tags:?}" ) ; 
296406            assert ! ( tags. contains( "si_signo:11" ) ,  "{tags:?}" ) ; 
297-             assert ! ( 
298-                 tags. contains( "si_code:1" )  || tags. contains( "si_code:2" ) , 
299-                 "{tags:?}" 
300-             ) ; 
301407        } 
302408        _ => panic ! ( "{crash_typ}" ) , 
303409    } 
0 commit comments