--- Begin Message ---
Subject: |
Mail delivery failed: returning message to sender |
Date: |
Mon, 03 Nov 2003 10:42:39 -0500 |
This message was created automatically by mail delivery software.
A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:
pipe to | /usr/lib/gnats/queue-pr -q
generated by address@hidden
(ultimately generated from address@hidden)
local delivery failed
------ This is a copy of the message, including all the headers. ------
Return-path: <address@hidden>
Received: from monty-python.gnu.org ([199.232.76.173])
by fencepost.gnu.org with esmtp (Exim 4.24)
id 1AGgql-0006W0-Ex
for address@hidden; Mon, 03 Nov 2003 10:42:39 -0500
Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24)
id 1AGgvZ-0008Jb-EQ
for address@hidden; Mon, 03 Nov 2003 10:48:08 -0500
Received: from [193.180.23.12] (helo=usagi.ingate.se)
by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168)
(Exim 4.24)
id 1AGgY7-0005hX-Fp
for address@hidden; Mon, 03 Nov 2003 10:23:23 -0500
Received: from yagi.ingate.se (IDENT:40Aeev5jviMEvLV048/address@hidden
[193.180.23.16])
by usagi.ingate.se (8.12.8/8.11.6) with ESMTP id hA3FNFs7032014;
Mon, 3 Nov 2003 16:23:15 +0100
Received: from yagi.ingate.se (IDENT:address@hidden [127.0.0.1])
by yagi.ingate.se (8.12.8/8.11.6) with ESMTP id hA3FNFGL027355;
Mon, 3 Nov 2003 16:23:15 +0100
Received: (from address@hidden)
by yagi.ingate.se (8.12.8/8.12.8/Submit) id hA3FNFHF027353;
Mon, 3 Nov 2003 16:23:15 +0100
Date: Mon, 3 Nov 2003 16:23:15 +0100
Message-Id: <address@hidden>
From: address@hidden
CC: address@hidden
To: address@hidden
Subject: Assigning stdout confuses printf
X-Spam-Status: No, hits=0.8 required=5.0
tests=NO_REAL_NAME
version=2.55
X-Spam-Level:
X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp)
>Submitter-Id: net
>Originator:
>Organization:
Per Cederqvist <address@hidden>, Director Development, Ingate Systems AB
>
>Confidential: no
>Synopsis: printf prints to wrong file after assignment to stdout
>Severity: serious
>Priority: medium
>Category: libc
>Class: sw-bug
>Release: libc-2.3.2
>Environment:
Host type: i386-redhat-linux-gnu
System: Linux yagi.ingate.se 2.4.20-20.9 #1 Mon Aug 18 11:45:58 EDT 2003 i686
i686 i386 GNU/Linux
Architecture: i686
Also tested on a home-grown Linux box running a pristine copy of
libc-2.3.1 compiled using a pristine copy of gcc-3.2.1.
Addons: linuxthreads c_stubs glibc-compat
Build CFLAGS: -march=i386 -DNDEBUG=1 -finline-limit=2000 -g -O3
Build CC: gcc
Compiler version: 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
Kernel headers: 2.4.22
Symbol versioning: yes
Build static: yes
Build shared: yes
Build pic-default: no
Build profile: yes
Build omitfp: no
Build bounded: no
Build static-nss: no
>Description:
If you assign to stdout, as the FAQ of glibc says that you can do, not
all output will be affected by the assignment. Some output will
continue to be sent to the old stream.
If you compile with -O2, a printf with a constant single-character
string will end up in the wrong place. If you compile without
optimization, calls to putchar() will end up in the wrong place.
>How-To-Repeat:
See this transcript:
$ cat demo.c
#include <stdio.h>
int main(void)
{
FILE *fp = fopen("demo.txt", "w");
if (!fp)
{
perror("fopen");
exit(1);
}
stdout = fp;
printf("Dem");
printf("o");
printf("\n");
putchar('t');
putchar('e');
putchar('s');
putchar('t');
putchar('\n');
}
$ gcc -O2 demo.c
$ ./a.out
o
$ cat demo.txt
Demtest
$ gcc demo.c
$ ./a.out
test
$ cat demo.txt
Demo
$ exit
Script done on Mon Nov 3 16:20:32 2003
>Fix:
Unknown.
--- End Message ---