Skip to content

Criterion on Docker issue #586

@matteoepitech

Description

@matteoepitech

Hi everyone,

I'm running into a strange issue and I’m hoping someone here has seen this before.

I'm on a Mac ARM M3, and I use Docker to compile x86_64 Ubuntu projects. After installing the libcriterion-dev package inside the container, I can compile my program with -lcriterion --coverage just fine.

However, when I try to run it inside Docker, the test binary gets stuck in an infinite loop.

If I run ./a.out -v, Criterion correctly prints version 2.4.1.
If I run ./a.out --verbose, it prints the test suite header… and then hangs forever.

What’s weird is that running the exact same test on my Mac (ARM) works perfectly, no infinite loop.

The test itself is extremely simple:

#include <criterion/criterion.h>

Test(simple, ok_test) {
    cr_assert_eq(1, 1);
}

Test(simple, fail_test) {
    cr_assert_eq(1, 2);
}

Compiled with: gcc test_basic.c -lcriterion --coverage && ./a.out

And here’s the strangest part:
If I run it with strace -f ./a.out inside Docker, it finishes normally and even generates the coverage output. So it only hangs when NOT traced (i guess).

This makes me think:
Could this be a race condition? Maybe strace slows the execution down just enough to avoid the issue?
Or could it be something related to Docker’s virtualization?

If anyone has experienced something similar, I'd be glad to discuss it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions