HylaFAX The world's most advanced open source fax server

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Re: A clue: mailer died with signal 13

Hi Eloy,

Firstly for hylafax, i think the following lines in util/TextFmt.c++ should
be changed from:
(starting line 322)

if (fclose(tf))
        fatal("%s: Close failure on temporary file: %s",
            (const char*) tempfile, strerror(errno));


if (fclose(tf))
        fatal("%s: Close failure on temporary file: %s",
            (const char*) tempfile, strerror(errno));
tf = NULL;

According to the link below it is an error to try and close a file twice,
even though libc5 and apparently most other libc's permitted it.(i tried on
hpux it works there)

The problem is the tf variable is just a pointer to a structure containing
details about the file, after fclose() is run the memory is deallocated and
your left with a dangling pointer!!

Unless the structure had some kind of magic number in it, it would be very
hard for fclose() to tell the second time around it had garbage or not.
Looking at the man page i think the EBADF error might be referring to a
FILE structure with an invalid file no in it ie there was a FILE structure
at the end of the pointer not something random, though i am not absolutely

Below is a link to an interesting email from 12 months ago that altavista


I have a current patch for textfmt, that i hope will make it into pl3, i
can easily add the lines above to fix the problem.

I also checked on redhat 5.0 with both glib-2.0.5 and glib-2.0.7, core
dumped on both ;-)

PS I cc'ed this to the mailing list.

PPS On a completely different subject, your running a debian system aren't
you? does it have the /dev/cua* devices present.

Thanks - Robert

At 01:17 10/04/98 -0400, you wrote:
>Hi again,
>> Line 88 is the fclose() statement, the tf might not be a valid file handle
>> try commenting that out.
>Bad news (or may be good news?): fclose() does not like to be passed a
>invalid stream as argument. This simple C program crashes with libc6:
>#include <stdio.h>
>void main(void)
>    FILE *fp;
>    fp = fopen("file.txt", "r");
>    fclose(fp);
>    fclose(fp);
>If file.txt does not exist, the program crashes in the first fclose().
>If file.txt does exist, it crashes on the second fclose().
>I think we've found a bug in libc (and it is not me fixing it :-).
>fclose()'s man page clearly states that EOF is returned and errno is
>set to EBADF in case the argument is not an open stream.
>Under libc5 the same program runs fine if file.txt exists but crashes
>if it doesn't.
>I'm shocked, aren't you?
>Bye for now.
>Eloy A. Paris
>Information Technology Department
>Rockwell Automation de Venezuela
>Telephone: +58-2-9432311 Fax: +58-2-9431645

Project hosted by iFAX Solutions