Skip to content
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

Panic message not printed correctly #483

Closed
tiziano88 opened this issue Jan 16, 2020 · 5 comments
Closed

Panic message not printed correctly #483

tiziano88 opened this issue Jan 16, 2020 · 5 comments
Assignees
Labels
bug Something isn't working lang/Rust

Comments

@tiziano88
Copy link
Collaborator

The error currently shows as

2020-01-16 17:03:46,825 ERROR [oak] panic occurred in file 'abitest/tests/src/tests.rs' at line 76: <UNKNOWN MESSAGE>

To reproduce, add assert_eq!(1, 2) to some function under test, e.g.:

#[test]
#[serial(node_test)]
fn test_abi() {
// Initialize the test logger first, so logging gets redirected to simple_logger.
// (A subsequent attempt to use the oak_log crate will fail.)
oak_tests::init_logging();
let mut entrypoints = HashMap::new();
let fe: oak_runtime::NodeMain = abitest_0_frontend::main;
let be: oak_runtime::NodeMain = abitest_1_backend::main;
entrypoints.insert(FRONTEND_CONFIG_NAME.to_string(), fe);
entrypoints.insert(BACKEND_CONFIG_NAME.to_string(), be);
assert_eq!(Some(()), oak_tests::start(test_config(), entrypoints));
let mut req = ABITestRequest::new();
// Skip raw tests (which use invalid memory addresses etc.).
req.exclude = "Raw".to_string();
let result: grpc::Result<ABITestResponse> =
oak_tests::inject_grpc_request("/oak.examples.abitest.OakABITestService/RunTests", req);
assert_matches!(result, Ok(_));
assert_eq!(OakStatus::ERR_TERMINATED, oak_tests::stop());
for result in result.unwrap().get_results() {
info!(
"[ {} ] {}",
if result.success { " OK " } else { "FAIL" },
result.name
);
if !result.success {
error!("Failure details: {}", result.details);
}
assert_eq!(true, result.success);
}
}

and then run the tests locally with cargo test.

Note that panic!("xxx") seems to show up fine instead, not sure if assert_eq is using a different mechanism behind the scenes.

I also noticed similar errors a few times when running compiled code on the Oak Runtime, but I don't have reproducibility steps for that yet.

@conradgrobler could you take a look? @daviddrysdale may have some thoughts about it too

@tiziano88 tiziano88 added bug Something isn't working lang/Rust labels Jan 16, 2020
@daviddrysdale
Copy link
Contributor

The <UNKNOWN MESSAGE> indicates that the panic hook that we register in oak::set_panic_hook has been unable to retrieve the payload from the PanicInfo. Dunno (yet) why that should happen for a panic! generated from the assert_eq! macro but not from an unadorned panic!.

@daviddrysdale
Copy link
Contributor

The panic details are also lost if a plain panic! has arguments (e.g. panic!("some {:?} thing", 1);). Maybe it's a Rust bug/limitation?

@daviddrysdale
Copy link
Contributor

rust-lang/rust#66745 looks potentially relevant.

@conradgrobler
Copy link
Collaborator

Changing the custom panic hook to handle the downcasting in a way that is more similar to the default hook should resolve it.

https://github.com/rust-lang/rust/blob/7d761fe0462ba0f671a237d0bb35e3579b8ba0e8/src/libstd/panicking.rs#L171-L177

@conradgrobler
Copy link
Collaborator

Resolved by #485

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lang/Rust
Projects
None yet
Development

No branches or pull requests

3 participants