bug-gnu-utils
[Top][All Lists]
Advanced

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

Fwd: Re: gettext-0.16.1: file vasprintf.c is wrong on amd64 bit


From: Cristian Baboi
Subject: Fwd: Re: gettext-0.16.1: file vasprintf.c is wrong on amd64 bit
Date: Tue, 25 Sep 2007 08:26:08 +0300
User-agent: Opera Mail/9.23 (Win32)



------- Forwarded message -------
From: "Cristian Baboi" <address@hidden>
To: "Bruno Haible" <address@hidden>
Cc:
Subject: Re: gettext-0.16.1: file vasprintf.c is wrong on amd64 bit
Date: Tue, 25 Sep 2007 08:25:03 +0300

On Tue, 25 Sep 2007 02:04:26 +0300, Bruno Haible <address@hidden> wrote:

Hello,

Cristian Baboi wrote:
#!./bin/sh
echo "">config.h
gcc -m64 -D TEST -I .
./a.out

The code does not compile.
See attachment.

Thank you for reporting this. Indeed, a call to va_copy is missing here,
since a va_list can only be traversed once, not twice. I have applied the
appended patch. But I don't understand the need for va_copy in the second
part of your patch. Why should that be needed?

I don't know why, but otherwise here is what I get:

PASS: 33 620782629
PASS:
236
808464933
PASS: 337
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000808660517
PASS: 290
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000808464677
Segmentation fault <----------- see ?

This are the compile warnings from gcc:
vasprintf.c: In function `vasprintf':
vasprintf.c:125: warning: passing arg 3 of `int_vasprintf' from
incompatible pointer type

g++ said:
vasprintf.c: In function `int int_vasprintf(char**, const char*,
__va_list_tag (*)[1])':
vasprintf.c:115: error: invalid conversion from `void*' to `char*'
vasprintf.c: In function `int vasprintf(char**, const char*,
__va_list_tag*)':
vasprintf.c:125: error: cannot convert `__va_list_tag**' to `__va_list_tag
(*)[1]' for argument `3' to `int int_vasprintf(char**, const char*,
__va_list_tag (*)[1])'


I tested on RHEL AS 4 and Solaris 10 x86 (with the SunStudio 12 compiler)
and the same thing (seg. fault) happen.
Without the first va_copy, it would not compile at all (when using -m64
flag).

2007-09-24  Bruno Haible  <address@hidden>

        * lib/vasprintf.c (int_vasprintf): Use va_copy.
        * modules/vasprintf.diff: Add dependency to stdarg.
        Reported by Cristian Baboi <address@hidden>.

*** lib/vasprintf.c     13 May 2007 23:06:17 -0000      1.3
--- lib/vasprintf.c     24 Sep 2007 23:02:46 -0000
***************
*** 38,45 ****
    /* Add one to make sure that it is never zero, which might cause
malloc
       to return NULL.  */
    size_t total_width = strlen (format) + 1;
!   va_list ap = *args;
   while (*p != '\0')
      {
        if (*p++ == '%')
--- 38,46 ----
    /* Add one to make sure that it is never zero, which might cause
malloc
       to return NULL.  */
    size_t total_width = strlen (format) + 1;
!   va_list ap;
+   va_copy (ap, *args);
    while (*p != '\0')
      {
        if (*p++ == '%')


-------------------------------------------------------------
This mail was scanned by BitDefender
For more informations please visit http://www.bitdefender.com


-------------------------------------------------------------




-------------------------------------------------------------
This mail was scanned by BitDefender
For more informations please visit http://www.bitdefender.com


------------------------------------------------------------





reply via email to

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