chicken-hackers
[Top][All Lists]
Advanced

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

Re: [Chicken-hackers] Fix attempt for bug #1269 "Port or reader state co


From: Evan Hanson
Subject: Re: [Chicken-hackers] Fix attempt for bug #1269 "Port or reader state corruption"
Date: Tue, 29 Mar 2016 11:42:43 +1300

Hi Kooda,

On 2016-03-25 17:30, Kooda wrote:
> [... various POSIX absurdities...]

What a mess.

> From this, I only see a handful ways of working around the bug:
> 
> - Calling _exit() instead of exit() in the default exit-handler. This
>   would prevent the streams from synchronizing with their FDs but
>   would completely throw away functions registered with atexit() or
>   on_exit()

This seems like an acceptable solution to me. We already use _exit() to
avoid similar shenanigans when a thunked child process exits implicitly,
and we currently make no guarantees about atexit() handlers so at least
we won't be breaking any declared functionality. There's also `on-exit`,
which *is* correctly inherited.

> - Calling fflush() on every input file owned by CHICKEN before calling
>   fork(). This would require a way to get all FILE* streams opened by
>   CHICKEN, I don?t know if we have that. 

We don't have that, and the overhead of global FILE* tracking is too
high a price to pay for such a stupid issue.

>   It would not cause the atexit() problem mentioned earlier, but it
>   wouldn?t be completely general, as we wouldn?t be able to call
>   fflush() on streams not owned by CHICKEN.

Also this. And again, I don't really see the atexit() problem as much of
one.

> Anyhow, we should at least add a call to fflush(NULL) in the
> process-fork procedure, as it takes care of the output streams.

Agreed. If only that were enough.

Anyway, your patch seems like it's on the right track to me. Thanks for
investigating this, Kooda.

Evan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]