File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,8 @@ pub enum SyscallName {
129129 WaitOnAddress ,
130130 #[ cfg( windows) ]
131131 WSAPoll ,
132+ /// panic!
133+ panicking,
132134}
133135
134136impl SyscallName {
Original file line number Diff line number Diff line change @@ -80,6 +80,35 @@ impl Monitor {
8080 match self . state . get ( ) {
8181 MonitorState :: Created => {
8282 self . state . set ( MonitorState :: Running ) ;
83+ // install panic hook
84+ std:: panic:: set_hook ( Box :: new ( |panic_hook_info| {
85+ let syscall = crate :: common:: constants:: SyscallName :: panicking;
86+ if let Some ( co) = crate :: scheduler:: SchedulableCoroutine :: current ( ) {
87+ let new_state = crate :: common:: constants:: SyscallState :: Executing ;
88+ if co. syscall ( ( ) , syscall, new_state) . is_err ( ) {
89+ error ! (
90+ "{} change to syscall {} {} failed !" ,
91+ co. name( ) ,
92+ syscall,
93+ new_state
94+ ) ;
95+ }
96+ }
97+ eprintln ! (
98+ "panic hooked in open-coroutine, thread '{}' {}" ,
99+ std:: thread:: current( ) . name( ) . unwrap_or( "unknown" ) ,
100+ panic_hook_info
101+ ) ;
102+ eprintln ! (
103+ "stack backtrace:\n {}" ,
104+ std:: backtrace:: Backtrace :: force_capture( )
105+ ) ;
106+ if let Some ( co) = crate :: scheduler:: SchedulableCoroutine :: current ( ) {
107+ if co. running ( ) . is_err ( ) {
108+ error ! ( "{} change to running state failed !" , co. name( ) ) ;
109+ }
110+ }
111+ } ) ) ;
83112 // install SIGURG signal handler
84113 let mut set = SigSet :: empty ( ) ;
85114 set. add ( Signal :: SIGURG ) ;
Original file line number Diff line number Diff line change @@ -192,6 +192,7 @@ impl<'o> Operator<'o> {
192192 Ok ( ( cq. len ( ) , cq, timeout. map ( |t| t. saturating_sub ( cost) ) ) )
193193 }
194194
195+ #[ allow( warnings) ]
195196 pub ( crate ) fn async_cancel ( & self , user_data : usize ) -> std:: io:: Result < ( ) > {
196197 todo ! ( "CancelIoEx" )
197198 }
You can’t perform that action at this time.
0 commit comments