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
Exit with a non-zero exitcode if the kernel panics. #7
Comments
This is can easily be implemented, as the signal for the shutdown of the hypervisor is writing an value to a certain COM port. So you can return an arbitrary return code from the application and for example return another value in the panic handler than on regular shutdown. I've already implemented this for uhyve's little sibling - ehyve. It can be easily backported for uhyve. Would this be sufficient? |
Yes, That would be absolutely sufficient. Thanks for your help :) |
Took me embarrasingly long to realize, but this is actually the behaviour that uhyve has by default. Panicing#[cfg(target_os = "hermit")]
extern crate hermit_sys;
fn main() {
println!("Hello World!");
panic!("asdf");
} > cargo build -Z build-std=std,core,alloc,panic_abort --target x86_64-unknown-hermit
# [...]
> uhyve target/x86_64-unknown-hermit/debug/hermit-new
Hello World!
thread 'main' panicked at 'asdf', src/main.rs:6:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
> echo $?
255 Return Error#[cfg(target_os = "hermit")]
extern crate hermit_sys;
use std::io::{Error, ErrorKind};
fn main() -> Result<(), std::io::Error> {
println!("Hello World!");
Err(Error::new(ErrorKind::Other, "oh no!"))
} > uhyve target/x86_64-unknown-hermit/debug/hermit-new
Hello World!
Error: Custom { kind: Other, error: "oh no!" }
> echo $?
1 |
I'd like to reopen this issue. I checked and the two examples you posted work for me too. However this does not work for all cases.
This also shows an issue that rusty-hermit may have when handling panics, but I should probably create a separate issue for that, since that isn't uhyve related. Output of step 13
|
Ok, seems that a userspace panic produces a correct return value, but a panic in the kernel code does not. |
I'd like to link to the Travis CI build for commit 4a2381c. In release mode it seems a race condition occured that caused a Panic due to a BorrowError: I've saved the log output here so it doesn't get lost if someone reruns the build. |
I'm updating this Issue, since apparently it is still relevant. |
Uhyve should exit with a non-zero exitcode if the kernel panics. This is important for testing rusty-hermit with uhyve and CI, since I'm not a fan of parsing the output of stdout or stderr to determine if a program failed.
I'm not sure if Uhyve always returns a zero, but at least in the cases I've seen where uhyve shuts down due to a panic of the kernel, the exit code was zero.
The text was updated successfully, but these errors were encountered: