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

Segmentation errors not being backtraced. #47

Open
daxida opened this issue Mar 16, 2024 · 0 comments
Open

Segmentation errors not being backtraced. #47

daxida opened this issue Mar 16, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@daxida
Copy link
Collaborator

daxida commented Mar 16, 2024

Describe the bug
If you get a SEGFAULT in C, the run command output message is inconsistent.

STDOUT and STDERR being UB is acceptable I guess, but it really should notify the SEGFAULT if it's possible.

Apparently it is also inconsistent in CG, so it may be hard to fix.

To Reproduce
Write this C code in a tmp.c file at the root:

#include <stdio.h>

int main() {
    printf("Before SEGFAULT\n");
    fprintf(stderr, "STDERR Before SEGFAULT\n");

    // This doesn't SEGFAULT in CG but it does for me... weird
    // int seg[10];
    // seg[11] = -1;

    // This segfaults in CG but doesnt backtrace the faulty line
    // int seg[10];
    // seg[1000] = -1;

    int *ptr = NULL;
    *ptr = 10;

    printf("After SEGFAULT\n");
    fprintf(stderr, "STDERR After SEGFAULT\n");

    return 0;
}

Load any clash, then run the command:
cargo run -- run --build-command "gcc -o tmp tmp.c" --command "./tmp"

Expected behavior
image

What happens
image

@daxida daxida added the bug Something isn't working label Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant