bootstrap/7312: bootstrap failure due to invalid use of errno

Bruno Haible bruno@clisp.org
Mon Jul 15 07:46:00 GMT 2002


>Number:         7312
>Category:       bootstrap
>Synopsis:       bootstrap failure due to invalid use of errno
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 15 05:36:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Bruno Haible
>Release:        3.1
>Organization:
GNU hackers
>Environment:
System: FreeBSD linuix.math.u-bordeaux.fr 4.0-RELEASE FreeBSD 4.0-RELEASE #0: Mon Mar 20 22:50:22 GMT 2000 root@monster.cdrom.com:/usr/src/sys/compile/GENERIC i386


        
host: i486-pc-freebsd-gnu
build: i486-pc-freebsd-gnu
target: i486-pc-freebsd-gnu
configured with: /gnu/build/gcc-3.1/configure --enable-shared --disable-nls --prefix=/gnu/usr --with-local-prefix=/gnu/usr/local --with-as=/gnu/usr/bin/as --with-gnu-as --with-ld=/gnu/usr/bin/ld --with-gnu-ld --enable-languages=c --enable-threads i486-pc-freebsd-gnu
>Description:

Bootstrapping gcc leads to this error message during stage2:

stage1/xgcc -Bstage1/ -B/gnu/tools/i486-pc-freebsd-gnu/bin/ -c -DIN_GCC    -g -O2 -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wtraditional -pedantic -Wno-long-long  -DHAVE_CONFIG_H    -I. -I. -I/gnu/build/gcc-3.1/gcc -I/gnu/build/gcc-3.1/gcc/. -I/gnu/build/gcc-3.1/gcc/config -I/gnu/build/gcc-3.1/gcc/../include /gnu/build/gcc-3.1/gcc/lists.c -o lists.o
In file included from /gnu/build/gcc-3.1/gcc/system.h:157,
                 from /gnu/build/gcc-3.1/gcc/lists.c:23:
/gnu/tools/i486-pc-freebsd-gnu/include/unistd.h:500:27: bits/confname.h: No such file or directory

The include file bits/confname.h exists under one of the -I directories. The
problem is that find_or_create_entry() returns a splay_tree_node containing
'struct include_file' with err_no == ENOMEM, which then causes open_file()
to behave as if the file did not exist. Now where does this ENOMEM come
from? In find_or_create_entry(), right after the _cpp_simplify_pathname call,
errno is 0, because the file exists. Then inside xcnew() malloc() is called,
which clobbers ENOMEM. (At this point one of the malloc() strategies fails,
brk() returns ENOMEM, and malloc() falls back on mmap().) The assumption
that errno is not clobbered by successful calls to malloc() is invalid.

>How-To-Repeat:

On a FreeBSD system with glibc chroot environment, configure gcc as described
above and run "make bootstrap".

>Fix:
Apply this patch.

2002-07-14  Bruno Haible  <bruno@clisp.org>

	* cppfiles.c (find_or_create_entry): Fetch errno immediately after
	_cpp_simplify_pathname returns.

*** gcc-3.1/gcc/cppfiles.c.bak	Fri Jan 18 14:40:28 2002
--- gcc-3.1/gcc/cppfiles.c	Sun Jul 14 01:16:19 2002
***************
*** 193,203 ****
--- 193,205 ----
       cpp_reader *pfile;
       const char *fname;
  {
+   int saved_errno;
    splay_tree_node node;
    struct include_file *file;
    char *name = xstrdup (fname);
  
    _cpp_simplify_pathname (name);
+   saved_errno = errno;
    node = splay_tree_lookup (pfile->all_include_files, (splay_tree_key) name);
    if (node)
      free (name);
***************
*** 205,211 ****
      {
        file = xcnew (struct include_file);
        file->name = name;
!       file->err_no = errno;
        node = splay_tree_insert (pfile->all_include_files,
  				(splay_tree_key) file->name,
  				(splay_tree_value) file);
--- 207,213 ----
      {
        file = xcnew (struct include_file);
        file->name = name;
!       file->err_no = saved_errno;
        node = splay_tree_insert (pfile->all_include_files,
  				(splay_tree_key) file->name,
  				(splay_tree_value) file);





>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list