Closed iphydf closed 6 months ago
Another segfault, I didn't check if it's the same root cause:
#include <ownership.h>
typedef struct Foo {
int *owner p;
} Foo;
Foo *owner foo_new(void) {
Foo *owner foo = (Foo *owner)calloc(1, sizeof(Foo));
if (foo == NULL) {
return NULL;
}
return foo;
}
The static variables state were not begin tracked.
struct a {
char b;
} c;
void d() {
struct a e = c;
}
here is the plan... initialize the global variables at declaration. if it is const the state if fixed in all the program. if the it is not const, each time we enter in a function the state will be "unknown" at the begging of the function. not sure how to implement. maybe at first usage inside the function make it "unknown" then i put in a list "already used".
Cool, then the second one is a separate bug.
this sample also needs attention
void d() {
static struct a { char b;} c;
struct a e = c;
}
I fixed the segmentation fault, but the state of global variables still wrong. I need to reset the state of global variables.
created global variables with -fanalyzer #150
segmentation fault fixed
crash.c:
Invocation:
cake -fanalyzer crash.c
Segfault happens here: https://github.com/thradams/cake/blob/e322139e9d493c2c7b9f9614037a5e5b569bd69e/src/object.c#L633