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

tests failings with (signal: 6, SIGABRT: process abort signal) #491

Closed
infiniteregrets opened this issue Jun 15, 2023 · 3 comments · Fixed by #516
Closed

tests failings with (signal: 6, SIGABRT: process abort signal) #491

infiniteregrets opened this issue Jun 15, 2023 · 3 comments · Fixed by #516
Labels
question Usage question

Comments

@infiniteregrets
Copy link

infiniteregrets commented Jun 15, 2023

I have some mock tests, and everytime I am experimenting with an expectation like something which might or might not be the tests fail... with (signal: 6, SIGABRT: process abort signal)

0 142.2 running 15 tests
#0 142.2 test env::tests::default ... ok
#0 142.2 test env::tests::include ... ok
#0 142.2 test env::tests::default_exclude ... ok
#0 142.2 test steal::ip_tables::redirect::tests::add_redirect_twice ... ok
#0 142.2 test steal::ip_tables::redirect::tests::add_redirect ... ok
#0 142.2 test steal::ip_tables::mesh::tests::add_redirect ... ok
#0 142.2 test steal::ip_tables::redirect::tests::remove_redirect ... ok
#0 142.2 test util::indexallocator_tests::check_max ... ok
#0 142.2 test util::indexallocator_tests::sanity ... ok
#0 142.2 test util::indexallocator_tests::sanity_buffer ... ok
#0 142.2 test util::subscription_tests::sanity ... ok
#0 142.2 test steal::ip_tables::tests::linkerd ... ok
#0 142.2 test watched_task::test::simple_successful ... ok
#0 142.2 test watched_task::test::simple_failing ... ok
#0 142.3 thread panicked while panicking. aborting.
#0 142.4 error: test failed, to rerun pass `-p mirrord-agent --bin mirrord-agent`
#0 142.4 
#0 142.4 Caused by:
#0 142.4   process didn't exit successfully: `/app/target/debug/deps/mirrord_agent-de17d317f3930445` (signal: 6, SIGABRT: process abort signal)

link to the tests https://github.com/metalbear-co/mirrord/blob/main/mirrord/agent/src/steal/ip_tables.rs#L193

for more context, i made some changes to the function that takes in the mock object, i.e. the trait being mocked will have more calls to its functions, now when I add an expectation it just fails with the error i described the SIGABRT or errors without giving me context, as to how my added expectation is different from the one which the function being expected was called?

the failure has ??? i would expect to know how the expectation is different..

failures:

---- steal::ip_tables::tests::default stdout ----
thread 'steal::ip_tables::tests::default' panicked at 'MockIPTables::insert_rule(?, ?, ?): No matching expectation found', mirrord/agent/src/steal/ip_tables.rs:55:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Am i missing something? any macros that i should add?

@asomers
Copy link
Owner

asomers commented Jun 15, 2023

The ? character is there because Mockall can't display arguments unless you enable the nightly feature. Do that, and you'll get better error messages. As for the SIGABRT, that is probably not caused by Mockall. It looks like your test failed, and then something paniced during Drop. I would check all of your Drop implementations for code that might panic, like .unwrap() calls.

@asomers asomers added the question Usage question label Jun 15, 2023
@msr1k
Copy link

msr1k commented Sep 13, 2023

I encounted similar problems.

Though I don't know whether it related to this issue or not, but after some investigation about that,
I found that following code will cause the same result: panic while panicking (signal: 6, SIGABORT: process abort signal).
(If I changed times(0) into times(1), then this test passes.)

Are there some mistakes in this test?

#[cfg(test)]
use mockall::automock;

struct Foo {}

#[cfg_attr(test, automock)]
impl Foo {
    pub fn hello() { () }
}

#[cfg(test)]
mod t {
    use super::*;

    #[test]
    fn test_use_foo() {
        let ctx = MockFoo::hello_context();
        ctx.expect().times(0).return_const(());

        MockFoo::hello();
    }
}
  • mockall: 0.11.4
  • rust toolchain: stable-x86_64-unknown-linux-gnu 1.70.0

@asomers
Copy link
Owner

asomers commented Sep 13, 2023

Ahh, I see @msr1k . Thank you for the test case. This is actually a regression introduced by #443 , released in 0.11.4. Static methods that are called too many times (but not too few), will trigger this double panic. I'll fix it.

asomers added a commit that referenced this issue Sep 13, 2023
PR #443 ensured that static methods' expectations would be cleared on
Drop.  But it was only tested for methods that paniced due to too few
method calls.  For methods with too many calls it actually introduced a
double-panic.  Double panics are bad; they lead to processes getting
SIGABRT.  This was a regression in Mockall 0.11.4.

Fixes #491
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usage question
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants