apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@rowe-clan.net>
Subject Re: Crash in apr_file_close() (Win32)
Date Mon, 21 Sep 2009 16:50:39 GMT
Mladen Turk wrote:
> Indeed the crash happens on second _close(1) call.
> I presume the _close(x) should be called *only* if
> the file was dup2'ed (at least according to the comment
> in the code), so I'll try to figure out how to fix that
> unless Bill has some other ideas or suggestions.

The real question is what does MSVCRT80 do with _close(1) on an
application started as a service or in windows, where there is no
file in fd[1]?

The best would be to mark fd[1] as closed, and avoid closing it
again with _close[1], but report an error instead.

>> The following simple code reproduces such error:
>> apr_file_open_stdout(&file1, pool);
>> apr_file_open_stdout(&file2, pool);

The presumption here is that stdout opens two handles; but it does
not.  On all platforms, file1 == file2

>> apr_file_close(file1);
>> apr_file_close(file2); // <-- crash is here.

Agreed crashing isn't nice, but it's not incorrect; this is a code bug
attempting to close the same handle twice.  We should return an error
instead, however.

View raw message