bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH] Re: buggy vfprintf makes printf(1) segfault on freebsd 5.0


From: Jim Meyering
Subject: [PATCH] Re: buggy vfprintf makes printf(1) segfault on freebsd 5.0
Date: Tue, 30 Oct 2007 11:28:26 +0100

Bruno Haible <address@hidden> wrote:
>> This is probably worth working around.
>> Maybe it's done already, but currently I've turned
>> off printf-posix in coreutils:
>>
>>   freebsd$ ./printf %.2147483647f 1
>>   Segmentation fault (core dumped)
>
> Before working around it in gnulib:
>
> - Will you turn on some *printf-posix in coreutils again? (If not, it
>   buys coreutils nothing if gnulib works around it.)

Of course I'll turn it back on.  Though maybe not right away.
I'm trying to get a test release out, and there have been
at least two problems due to this module, so rather than
pressuring or waiting for you, I removed it.

> - Does it also occur if you include printf-posix in coreutils? (If not,
>   there's nothing to do.)

Yes.  The failure is due to the fact that the vprintf-posix module wasn't
even being pulled in.  Patch below.

> - Can you reduce the testcase to a smaller width value? I would not want
>   to include a test that produces 2 GB of output; even when piped to
>   /dev/null, it will likely take several seconds, which is too much for a
>   configure test.

Not easily, since then it actually succeeds on a few systems.
Even as written, I've found that it succeeds on FreeBSD 6.1.
This is precisely why I posted asking people to test this first.
But from the lack of feedback, it seems no one tested on the
affected systems.

It appears there are two new bugs afflicting libc *printf functions.
In order to test just the one that's fixed by using xprintf, I
think I'll have to resort to using a moderately large width, yet
with limited virtual memory, e.g., via ulimit -v 10000.  Of course,
I'll skip the test when ulimit doesn't work, which means I need
a test for a working shell ulimit.  Not hard, ... just more work.

Even with the following patch, and with printf-posix enabled, it
still fails, this time via libc's snprintf.

Starting program: /tmp/coreutils-6.9-365-b00f87-dirty/src/printf %.2147483647f 1
Program received signal SIGSEGV, Segmentation fault.
0x281efad3 in __vfprintf () from /usr/lib/libc.so.5
(gdb) bt
#0  0x281efad3 in __vfprintf () from /usr/lib/libc.so.5
#1  0x281ed709 in __vfprintf () from /usr/lib/libc.so.5
#2  0x281e9de1 in snprintf () from /usr/lib/libc.so.5
#3  0x0804df4e in vasnprintf (resultbuf=0xbfbff190 "", lengthp=0xbfbff18c,
    format=0x28063fff "", args=0xbfbff9e4 "") at vasnprintf.c:3597
#4  0x0804b6ea in rpl_vfprintf (fp=0x282079d8,
    format=0x8055030 "%.2147483647Lf", args=0xbfbff9e4 "") at vfprintf.c:50
#5  0x0804b777 in rpl_vprintf (format=0x8055030 "%.2147483647Lf",
    args=0xbfbff9e4 "") at vprintf.c:34
#6  0x0804a346 in xvprintf (format=0x8055030 "%.2147483647Lf",
    args=0xbfbff9e4 "") at xprintf.c:48
#7  0x0804a3a2 in xprintf (format=0x8055030 "%.2147483647Lf") at xprintf.c:37
#8  0x08049b9a in main (argc=1, argv=0xbfbffbb4) at printf.c:461

Plus, there's another bug, exposed by a seq test failure.
I'll report that one separately.

---------------------------
>From 2b655dcd55e669066836129883e5a5e5c0c41c98 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Tue, 30 Oct 2007 09:46:35 +0100
Subject: [PATCH] printf-posix: Depend on vprintf, not vfprintf.

* modules/printf-posix: Otherwise, applications could use a
buggy system vprintf, rather than our replacement.

Signed-off-by: Jim Meyering <address@hidden>
---
 ChangeLog            |    6 ++++++
 modules/printf-posix |    3 +--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3ef8818..0fa7ca1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-10-30  Jim Meyering  <address@hidden>
+
+       printf-posix: Depend on vprintf, not vfprintf.
+       * modules/printf-posix: Otherwise, applications could use a
+       buggy system vprintf, rather than our replacement.
+
 2007-10-30  Ralf Wildenhues  <address@hidden>

        * modules/fbufmode-tests (MOSTLYCLEANFILES): Remove temp files.
diff --git a/modules/printf-posix b/modules/printf-posix
index b690c72..97c13db 100644
--- a/modules/printf-posix
+++ b/modules/printf-posix
@@ -8,7 +8,7 @@ m4/printf.m4

 Depends-on:
 stdio
-vfprintf-posix
+vprintf-posix
 printf-safe

 configure.ac:
@@ -25,4 +25,3 @@ LGPL

 Maintainer:
 Bruno Haible
-
--
1.5.3.4.395.g85b0




reply via email to

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