Messages in this thread | | | Date | Thu, 13 Jul 2000 13:12:45 +0200 | From | Manfred Spraul <> | Subject | Re: SIGSEGV on fclose |
| |
Bjarne Blichfeldt wrote: > > Agreed, it took several days to track this one down in a program that > runs > without problems on all the unix'es. > > On scanning the net I noticed that other people have had the same > problem, > which is why I reported it here. >
I doubt that this can be fixed. FILE* is user space only in Linux, probably allocated with malloc. fclose frees the stream structure, there is not much that can be done to prevent the sigsegv.
So what you are asking for is that malloc should not SIGSEGV on
FILE* p = malloc(sizeof(FILE)); /* first fclose() */ p->x=y; free(p); /* second fclose() */ p->y=z; free(p);
Obviously this depends on the malloc implementation - some will sigsegv, some might ignore the second call, some might fail with an error message.
I assume that the other unices store a magic number within the stream structure, but that's ugly and doesn't guarantee an error message: you replace a 100% sigsegv with a rare race - I prefer the sigsegv.
-- Manfred
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |