lkml.org 
[lkml]   [2000]   [Jul]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 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/

\
 
 \ /
  Last update: 2005-03-22 13:57    [W:0.046 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site