[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Crash fix on Windows/MinGW
From: |
Paul Eggert |
Subject: |
Re: Crash fix on Windows/MinGW |
Date: |
Sun, 16 Apr 2006 23:16:38 -0700 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
Stepan Kasal <address@hidden> writes:
> What's the difference between:
>
> exec 5>foo
> cat >&5 <<END
> Prologue
> END
>
> and
>
> cat >foo <<END
> Prologue
> END
> exec 5>>foo
It affects whether O_APPEND is set in the file description
corresponding to file descriptor 5. O_APPEND causes all output to be
appended to the file, regardless of where the current seek position is.
> Can you imagine an Autoconf bug which would be caused by this?
Yes. In the former case a misbehaving script can lose parts of the log.
The most common error is something like this, executed after the above code:
echo log1 >>foo
echo log2 >&5
In the former case, "log1" will be overwritten and lost, which is bad.
Even in the latter case, a misbehaving script can lose parts of the
log by invoking fcntl to clear O_APPEND. But this is far, far less
likely in practice: I've never seen it, but I have seen problems like
the above in the former case.
> The reason is that I think we are in a ``freeze'' now.
We are not adding features, but we are fixing bugs. At this point, we
need not limit ourselves to bugs reported by users; we can fix bugs
that we find ourselves. The old code wasn't consistent about using
">>" to append to logs leading problems like the one mentioned above.
The new code is consistent.
> (A particular concern/superstition is about 5>&- to close a file descriptor;
Fair enough. I'll remove that. Though the usage is quite portable in
practice: it was in 7th edition Unix and I've never seen a shell where
it didn't work.
> A patch is attached below. What do you think about it?
Looks OK. Thanks. You did a deeper analysis of the problem than I
did. I installed it, along with the 5>&- removal, as follows (with a
slight reworking of comments):
2006-04-16 Paul Eggert <address@hidden>
* lib/autoconf/general.m4 (_AC_INIT_CONFIG_LOG): Don't
use ">&-" since we're only 99.999% sure that this is portable,
and since the MinGW bug is fixed in a different way.
* lib/autotest/general.m4 (AT_INIT): Likewise.
2006-04-16 Stepan Kasal <address@hidden>
* lib/autoconf/status.m4 (_AC_OUTPUT_CONFIG_STATUS): Handle --recheck
before opening config.log, to avoid hitting a bug on MinGW.
--- lib/autoconf/general.m4 15 Apr 2006 01:13:32 -0000 1.907
+++ lib/autoconf/general.m4 17 Apr 2006 06:01:22 -0000
@@ -1103,7 +1103,6 @@ fi])dnl
m4_define([_AC_INIT_CONFIG_LOG],
[m4_divert_text([INIT_PREPARE],
[m4_define([AS_MESSAGE_LOG_FD], 5)dnl
-exec AS_MESSAGE_LOG_FD>&- # Work around a MinGW bug.
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
--- lib/autotest/general.m4 15 Apr 2006 01:13:33 -0000 1.210
+++ lib/autotest/general.m4 17 Apr 2006 06:01:22 -0000
@@ -601,7 +601,6 @@ m4_define([AS_MESSAGE_LOG_FD], [5])
if $at_debug_p; then
at_suite_log=/dev/null
else
- exec AS_MESSAGE_LOG_FD>&- # Work around a MinGW bug.
: >"$at_suite_log"
fi
exec AS_MESSAGE_LOG_FD>>"$at_suite_log"
--- lib/autoconf/status.m4 12 Apr 2006 20:40:21 -0000 1.95
+++ lib/autoconf/status.m4 17 Apr 2006 06:01:22 -0000
@@ -1270,6 +1270,19 @@ if $ac_cs_silent; then
ac_configure_extra_args="$ac_configure_extra_args --silent"
fi
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+dnl Check this before opening the log, to avoid a bug on MinGW,
+dnl which prohibits the recursive instance from truncating an open log.
+if \$ac_cs_recheck; then
+ echo "running CONFIG_SHELL=$SHELL $SHELL $[0] " $ac_configure_args
\$ac_configure_extra_args " --no-create --no-recursion" >&AS_MESSAGE_FD
+ CONFIG_SHELL=$SHELL
+ export CONFIG_SHELL
+ exec $SHELL "$[0]" $ac_configure_args \$ac_configure_extra_args --no-create
--no-recursion
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
dnl Open the log:
m4_rename([_AC_save_AS_MESSAGE_LOG_FD], [AS_MESSAGE_LOG_FD])dnl
exec AS_MESSAGE_LOG_FD>>config.log
@@ -1281,12 +1294,6 @@ exec AS_MESSAGE_LOG_FD>>config.log
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
-if \$ac_cs_recheck; then
- echo "running CONFIG_SHELL=$SHELL $SHELL $[0] " $ac_configure_args
\$ac_configure_extra_args " --no-create --no-recursion" >&AS_MESSAGE_FD
- CONFIG_SHELL=$SHELL
- export CONFIG_SHELL
- exec $SHELL "$[0]" $ac_configure_args \$ac_configure_extra_args --no-create
--no-recursion
-fi
m4_ifdef([_AC_OUTPUT_COMMANDS_INIT],
[#
# INIT-COMMANDS