NetBSD-Bugs archive

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

Re: standards/47119: putc_unlocked(3) is found even with -std=c89



The following reply was made to PR standards/47119; it has been noted by GNATS.

From: Steffen "Daode" Nurpmeso <sdaoden%gmail.com@localhost>
To: christos%zoulas.com@localhost (Christos Zoulas)
Cc: standards-manager%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost,
 gnats-bugs%NetBSD.org@localhost, gnats-admin%netbsd.org@localhost
Subject: Re: standards/47119: putc_unlocked(3) is found even with -std=c89
Date: Wed, 24 Oct 2012 16:45:11 +0200

 christos%zoulas.com@localhost (Christos Zoulas) wrote:
 
  |On Oct 24,  2:10pm, sdaoden%gmail.com@localhost (Steffen "Daode" Nurpmeso) 
wrot=
 e:
  |-- Subject: Re: standards/47119: putc_unlocked(3) is found even with =
 \
  |-std=3Dc89
  |
  || The following reply was made to PR standards/47119; it has been not=
 ed by \
  |. GNATS.
  ||=20
  || From: Steffen "Daode" Nurpmeso <sdaoden%gmail.com@localhost>
  || To: Martin Husemann <martin%duskware.de@localhost>
  || Cc: gnats-bugs%NetBSD.org@localhost
  || Subject: Re: standards/47119: putc_unlocked(3) is found even with \
  |. -std=3Dc89
  || Date: Wed, 24 Oct 2012 16:05:07 +0200
  ||=20
  ||  Martin Husemann <martin%duskware.de@localhost> wrote:
  || =20
  |||On Wed, Oct 24, 2012 at 03:11:03PM +0200, Steffen Daode Nurpmeso wr=
 ote:
  |||> Because it is not part of C89/C99?
  |||
  |||You are misunderstanding the compiler option - it has no influence =
 on the
  |||symbols visible in libraries nor system headers (at least in genera=
 l).
  |||There are a few defines you can add via -D to make the headers poll=
 ute \
  |.. less
  || =20
  ||  Hmm.  I think you're right.
  ||  Well i'm not really working with those headers, and i still see
  ||  a '#define _GNU_SOURCE' on top of the one that's really important
  ||  for me.
  || =20
  |||namespace, but since this is a posix blessed function, it is better
  |||to avoid a name clash in application code.
  |||Martin
  || =20
  ||  Yes, a lot of conditions and a lot of what standards produce most
  ||  of the time, so thanks for all those work on standard compliance.
  || =20
  ||  Nonetheless - the bug is triggered only with -std=3Dc89, and only =
 on
  ||  NetBSD 6.0.  And in the meanwhile i've found it.
  ||  In fact it has nothing to do with putc_unlocked() (i was so clumsy
  ||  that i even tried to compile with -pthread and -D_REENTRANT, and
  ||  it was still expanded to __sputc() or so - amazing!), but it is in
  ||  fact alloca(3) that returns an invalid buffer:
  || =20
  ||    %fwrite_td() calls ac_alloc for 29
  ||    fwrite_td() calls memcpy (From: <XXXXXXXXXXX%YYYY.com@localhost>
  ||    )29
  ||    fwrite_td() before delctrl (^])29
  ||    fwrite_td() calls prefixwrite (^])29
  ||    *29 (0xbfbf9254)()*^@^@^@^@^@^@^@^@XXXXXXXXXX%YYYY.com@localhost>
  || =20
  ||  From the alloca(3) manual i see nothing special to adhere to,
  ||  i would not describe 29 bytes as a "large unbounded allocation".
  ||  The CFLAGS are simply '-std=3Dc89 -O2', so nothing special at all.
  ||  I think this is worth another PR?
  |
  |You are probably missing some include header (stdlib.h) and there
  |is no prototype for alloca()? Post the code...
  |
  |christos
 
 No no, that used to be Berkeley Mail before it was mangled ;)
 
 Breakpoint 1, fwrite_td (ptr=3D0xbb60c520, nmemb=3D29, f=3D0xbb9afea0, =
 flags=3DTD_NONE, prefix=3D0x0, prefixlen=3D0, size=3D1) at mime.c:1479
 1494            mptr =3D xmptr =3D ac_alloc(mptrsz + 1);
 0x0804b1ac in alloca@plt ()
 0xbb993192 in memcpy () from /lib/libc.so.12
 
 0x0804b1ac in alloca@plt ()
 
 gdb) print mptr
 $9 =3D 0xbfbf91f4 "p=0a=0r\277\277"
 
 (gdb) info registers esp
 esp            0xbfbf91e4       0xbfbf91e4
 
 (gdb) print (char*)ptr
 $10 =3D 0xbb60c520 "From: <Paul_Koning%Dell.com@localhost>\n"
 
 1517                    memcpy(mptr, ptr, csize);
 
 0x0804acac in memcpy@plt ()
 
 
 (gdb) print (char*)ptr
 $11 =3D 0xbb60c520 "From: <Paul_Koning%Dell.com@localhost>\n"
 (gdb) print (char*)mptr
 $12 =3D 0xbfbf91f4 "From: <Paul_Koning%Dell.com@localhost>\n"
 
 (gdb) print csize
 $13 =3D 29
 
 
 prefixwrite (ptr=3D0xbfbf91f4, size=3D1, nmemb=3D29, f=3D0xbb9afea0, pr=
 efix=3D0x0, prefixlen=3D0) at mime.c:1361
 1361    {
 
 
 (gdb) print rsz
 $14 =3D <optimized out>
 (gdb) print size
 $15 =3D 1
 (gdb) print nmemb
 $16 =3D 29
 (gdb)=20
 
 
 (gdb) print (char*)ptr
 $17 =3D 0xbfbf91f4 ""
 
 


Home | Main Index | Thread Index | Old Index