File tree Expand file tree Collapse file tree 3 files changed +10
-14
lines changed Expand file tree Collapse file tree 3 files changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ mod imp {
4242 use crate :: io;
4343 use crate :: mem;
4444 use crate :: ptr;
45+ use crate :: thread;
4546
4647 use libc:: MAP_FAILED ;
4748 use libc:: { mmap, munmap} ;
@@ -95,15 +96,16 @@ mod imp {
9596 info : * mut libc:: siginfo_t ,
9697 _data : * mut libc:: c_void ,
9798 ) {
98- use crate :: sys_common:: util:: report_overflow;
99-
10099 let guard = thread_info:: stack_guard ( ) . unwrap_or ( 0 ..0 ) ;
101100 let addr = siginfo_si_addr ( info) ;
102101
103102 // If the faulting address is within the guard page, then we print a
104103 // message saying so and abort.
105104 if guard. start <= addr && addr < guard. end {
106- report_overflow ( ) ;
105+ rterr ! (
106+ "\n thread '{}' has overflowed its stack\n " ,
107+ thread:: current( ) . name( ) . unwrap_or( "<unknown>" )
108+ ) ;
107109 rtabort ! ( "stack overflow" ) ;
108110 } else {
109111 // Unregister ourselves by reverting back to the default behavior.
Original file line number Diff line number Diff line change 11#![ cfg_attr( test, allow( dead_code) ) ]
22
33use crate :: sys:: c;
4- use crate :: sys_common :: util :: report_overflow ;
4+ use crate :: thread ;
55
66pub struct Handler ;
77
@@ -24,7 +24,10 @@ extern "system" fn vectored_handler(ExceptionInfo: *mut c::EXCEPTION_POINTERS) -
2424 let code = rec. ExceptionCode ;
2525
2626 if code == c:: EXCEPTION_STACK_OVERFLOW {
27- report_overflow ( ) ;
27+ rterr ! (
28+ "\n thread '{}' has overflowed its stack\n " ,
29+ thread:: current( ) . name( ) . unwrap_or( "<unknown>" )
30+ ) ;
2831 }
2932 c:: EXCEPTION_CONTINUE_SEARCH
3033 }
Original file line number Diff line number Diff line change 11use crate :: fmt;
22use crate :: io:: prelude:: * ;
33use crate :: sys:: stdio:: panic_output;
4- use crate :: thread;
54
65pub fn dumb_print ( args : fmt:: Arguments < ' _ > ) {
76 if let Some ( mut out) = panic_output ( ) {
87 let _ = out. write_fmt ( args) ;
98 }
109}
11-
12- #[ allow( dead_code) ] // stack overflow detection not enabled on all platforms
13- pub unsafe fn report_overflow ( ) {
14- dumb_print ( format_args ! (
15- "\n thread '{}' has overflowed its stack\n " ,
16- thread:: current( ) . name( ) . unwrap_or( "<unknown>" )
17- ) ) ;
18- }
You can’t perform that action at this time.
0 commit comments