Skip to content

Segmentation errors not being backtraced. #47

@daxida

Description

@daxida

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions