autoconf-patches
[Top][All Lists]
Advanced

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

Re: uninitialized variables


From: Ralf Wildenhues
Subject: Re: uninitialized variables
Date: Sun, 6 Nov 2005 23:17:33 +0100
User-agent: Mutt/1.5.9i

[ Moving from libtool-patches ]

* Ralf Wildenhues wrote on Sun, Nov 06, 2005 at 07:37:48PM CET:
> 
> I went through the fun of
>   sh -u configure
> adding environment variables until I hit bugs.

1) Nasty race condition: Let's assume I have $tmp set in my environment,
or in configure.ac; the status.m4 code uses it at the end of configure
to name a directory which is removed later by a trap.  However, the trap
is installed before $tmp is initialized.  If a signal arrives too early,
it might remove rather arbitrary files.

        * lib/autoconf/status.m4 (_AC_OUTPUT_MAIN_LOOP): Initialize
        `tmp' to avoid file removal race.

Index: lib/autoconf/status.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/status.m4,v
retrieving revision 1.77
diff -u -r1.77 status.m4
--- lib/autoconf/status.m4      21 Oct 2005 07:36:32 -0000      1.77
+++ lib/autoconf/status.m4      6 Nov 2005 19:41:17 -0000
@@ -1319,6 +1319,7 @@
 # Hook for its removal unless debugging.
 $debug ||
 {
+  tmp=
   trap 'exit_status=$?; rm -fr "$tmp" && exit $exit_status' 0
   trap 'AS_EXIT([1])' 1 2 13 15
 }



2) configure scripts use many uninitialized variables.  Most are either
supposed to be specified by the user and/or defaulted (like CC), or
cache variables `*_cv_*', or internal variables named `ac_*'.  Now while
I think it is ok not to initialize those, I believe variables outside
these "namespaces" should be initialized, unless their effect upon
configure invocation is documented.  Also, I believe all variables that
name files to remove should be initialized anyway, like ac_clean_files.

LIBOBJS
ac_clean_files
ac_config_files
ac_config_links
..
ac_vpsub
extrasub
ac_executable_extensions
ac_c_werror_flag
...

What do you think about the patch below?

Cheers,
Ralf

        * lib/autoconf/general.m4 (_AC_INIT_DEFAULTS): Initialize
        ac_clean_files and LIBOBJS.

Index: lib/autoconf/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/general.m4,v
retrieving revision 1.886
diff -u -r1.886 general.m4
--- lib/autoconf/general.m4     19 Oct 2005 05:21:23 -0000      1.886
+++ lib/autoconf/general.m4     6 Nov 2005 21:26:41 -0000
@@ -380,7 +380,9 @@
 # Initializations.
 #
 ac_default_prefix=/usr/local
+ac_clean_files=
 ac_config_libobj_dir=.
+LIB@&address@hidden
 cross_compiling=no
 subdirs=
 MFLAGS=




reply via email to

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