@@ -89,29 +89,29 @@ fn expect_aborted(status: ExitStatus) {
89
89
assert ! ( signal == libc:: SIGSEGV ) ;
90
90
91
91
// Additional checks performed:
92
- // 1. Crash is from same executable (path) as we are (must be because of fork):
92
+ // 1. Find last tombstone (similar to coredump but in text format) from the
93
+ // same executable (path) as we are (must be because of usage of fork):
93
94
// This ensures that we look into the correct tombstone.
94
95
// 2. Cause of crash is a SIGSEGV with address 0xdeadbaad.
95
96
// 3. libc::abort call is in one of top two functions on callstack.
96
97
// The last two steps distinguish between a normal SIGSEGV and one caused
97
98
// by libc::abort.
98
99
99
- let tombstone_name = ( 0 ..100 )
100
+ let this_exe = std:: env:: current_exe ( ) . unwrap ( ) . into_os_string ( ) . into_string ( ) . unwrap ( ) ;
101
+ let exe_string = format ! ( ">>> {this_exe} <<<" ) ;
102
+ let tombstone = ( 0 ..100 )
100
103
. map ( |n| format ! ( "/data/tombstones/tombstone_{n:02}" ) )
101
104
. filter ( |f| std:: path:: Path :: new ( & f) . exists ( ) )
105
+ . map ( |f| std:: fs:: read_to_string ( & f) . expect ( "Cannot read tombstone file" ) )
106
+ . filter ( |f| f. contains ( & exe_string) )
102
107
. last ( )
103
108
. expect ( "no tombstone found" ) ;
104
109
105
- let tombstone =
106
- std:: fs:: read_to_string ( & tombstone_name) . expect ( "Cannot read tombstone file" ) ;
107
- println ! ( "Content of {tombstone_name}:\n {tombstone}" ) ;
110
+ println ! ( "Content of tombstone:\n {tombstone}" ) ;
108
111
109
- // If the next assert fails sporadically we might have an issue with parallel crashing apps
110
- assert ! ( tombstone
111
- . contains( & std:: env:: current_exe( ) . unwrap( ) . into_os_string( ) . into_string( ) . unwrap( ) ) ) ;
112
- assert ! ( tombstone. contains(
113
- "signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad"
114
- ) ) ;
112
+ assert ! (
113
+ tombstone. contains( "signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad" )
114
+ ) ;
115
115
let abort_on_top = tombstone
116
116
. lines ( )
117
117
. skip_while ( |l| !l. contains ( "backtrace:" ) )
0 commit comments