-
-
Notifications
You must be signed in to change notification settings - Fork 468
Error handling for Launcher exits #3798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -762,7 +762,7 @@ where | |
| } | ||
| } | ||
|
|
||
| Self::wait_for_pids(&handles, self.spawn_broker); | ||
| Self::wait_for_pids(&handles, self.spawn_broker)?; | ||
| } | ||
| // This is the fork part for unix | ||
| #[cfg(not(unix))] | ||
|
|
@@ -892,13 +892,16 @@ where | |
| spawn_mgr(&self, None, monitor)?; | ||
| } | ||
|
|
||
| Self::wait_for_child_processes(&mut handles, self.spawn_broker); | ||
| Self::wait_for_child_processes(&mut handles, self.spawn_broker)?; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. delete |
||
| } | ||
| Ok(()) | ||
| Err(Error::shutting_down()) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete this line |
||
| } | ||
|
|
||
| #[cfg(unix)] | ||
| fn wait_for_pids(handles: &[i32], spawn_broker: bool) { | ||
| fn wait_for_pids(handles: &[i32], spawn_broker: bool) -> Result<(), Error> { | ||
| let mut crash_count = 0; | ||
| let mut reasons = vec![]; | ||
|
|
||
| if spawn_broker { | ||
| // Broker exited. kill all clients and wait for them to avoid zombies. | ||
| for handle in handles { | ||
|
|
@@ -927,26 +930,67 @@ where | |
| ); | ||
| } else { | ||
| log::info!("Client with pid {handle} exited with status {status}"); | ||
| crash_count += 1; | ||
| reasons.push(format!("Exited with status {status}")); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will get formatted weird by |
||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if crash_count > 0 { | ||
| return Err(Error::unknown(format!( | ||
| "{crash_count} child processes crashed. Reasons: {reasons:?}" | ||
| ))); | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn wait_for_child_processes(handles: &mut [std::process::Child], spawn_broker: bool) { | ||
| fn wait_for_child_processes( | ||
| handles: &mut [std::process::Child], | ||
| spawn_broker: bool, | ||
| ) -> Result<(), Error> { | ||
| let mut crash_count = 0; | ||
| let mut reasons = vec![]; | ||
|
|
||
| if spawn_broker { | ||
| for handle in &mut *handles { | ||
| let _ = handle.kill(); | ||
| let _ = handle.wait(); | ||
| } | ||
| } else { | ||
| for handle in &mut *handles { | ||
| let ecode = handle.wait(); | ||
| if ecode.as_ref().is_ok_and(|e| !e.success()) { | ||
| log::info!("Client with handle {handle:?} exited with {ecode:?}"); | ||
| let ecode = handle.wait()?; | ||
| if !ecode.success() { | ||
| #[cfg(unix)] | ||
| { | ||
| use std::os::unix::process::ExitStatusExt; | ||
| if let Some(sig) = ecode.signal() { | ||
| if sig != libc::SIGINT && sig != libc::SIGTERM { | ||
| crash_count += 1; | ||
| reasons.push(format!("Killed by signal {sig}")); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly here, might be better to make a function-specific derived-debug enum with |
||
| } | ||
| } else if let Some(code) = ecode.code() { | ||
| crash_count += 1; | ||
| reasons.push(format!("Exited with code {code}")); | ||
| } | ||
| } | ||
| #[cfg(not(unix))] | ||
| { | ||
| if let Some(code) = ecode.code() { | ||
| crash_count += 1; | ||
| reasons.push(format!("Exited with code {code}")); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if crash_count > 0 { | ||
| return Err(Error::unknown(format!( | ||
| "{crash_count} child processes crashed. Reasons: {reasons:?}" | ||
| ))); | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| /// Launch the common broker logic | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -198,7 +198,7 @@ fn main() { | |
| res | ||
| }; | ||
| match res { | ||
| Ok(()) => unreachable!(), | ||
| Ok(()) => (), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, this shouldn't be the case; forkserver should never return "Ok", this should indeed be unreachable. |
||
| Err(Error::ShuttingDown) => println!("Fuzzing stopped by user. Good bye."), | ||
| Err(err) => panic!("Failed to run launcher: {err:?}"), | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete
?;.