From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11853 invoked by alias); 15 Jul 2002 12:36:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 11821 invoked by uid 71); 15 Jul 2002 12:36:00 -0000 Resent-Date: 15 Jul 2002 12:36:00 -0000 Resent-Message-ID: <20020715123600.11820.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, Bruno Haible Received: (qmail 11784 invoked from network); 15 Jul 2002 12:35:51 -0000 Received: from unknown (HELO sceaux.ilog.fr) (193.55.64.10) by sources.redhat.com with SMTP; 15 Jul 2002 12:35:51 -0000 Received: from ftp.ilog.fr (ftp.ilog.fr [193.55.64.11]) by sceaux.ilog.fr (8.11.6/8.11.6) with SMTP id g6FCWdi21801 for ; Mon, 15 Jul 2002 14:32:44 +0200 (MET DST) Received: from laposte.ilog.fr ([193.55.64.67]) by ftp.ilog.fr (NAVGW 2.5.1.16) with SMTP id M2002071514353819674 for ; Mon, 15 Jul 2002 14:35:38 +0200 Received: from honolulu.ilog.fr ([172.17.4.204]) by laposte.ilog.fr (8.11.6/8.11.5) with ESMTP id g6FCZbw10961; Mon, 15 Jul 2002 14:35:37 +0200 (MET DST) Received: (from haible@localhost) by honolulu.ilog.fr (8.9.3/8.9.3/SuSE Linux 8.9.3-0.1) id OAA11445; Mon, 15 Jul 2002 14:37:14 +0200 Message-Id: <15666.49658.734634.850715@honolulu.ilog.fr> Date: Mon, 15 Jul 2002 05:36:00 -0000 From: Bruno Haible To: gcc-gnats@gcc.gnu.org Subject: bootstrap/7312: bootstrap failure due to invalid use of errno X-SW-Source: 2002-07/txt/msg00462.txt.bz2 List-Id: >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 * 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: