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

Bug#380195: marked as done (libc6: snprintf(buf, sizeof(buf), "%.2000000000s", "hello") may fail)



Your message dated Mon, 07 May 2007 07:17:05 +0000
with message-id <E1HkxSz-0005CN-9e@ries.debian.org>
and subject line Bug#421555: fixed in glibc 2.5-6
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--- Begin Message ---
Package: libc6
Version: 2.3.6-16
Severity: normal

Hello,

The following program prints "-1" rather than "5" on my laptop:

    #include <stdio.h>
    #include <limits.h>

    int main()
    {
	char buf[256];
	printf("%d\n", snprintf(buf, sizeof(buf), "%.2000000000s", "hello"));
	return 0;
    }

Here is the strace:

    execve("/tmp/a.out", ["/tmp/a.out"], [/* 95 vars */]) = 0
    uname({sys="Linux", node="ligate", ...}) = 0
    brk(0)                                  = 0x804a000
    access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
    mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f5c000
    access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
    mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f5b000
    open("/etc/ld.so.cache", O_RDONLY)      = 3
    fstat64(3, {st_mode=S_IFREG|0644, st_size=78547, ...}) = 0
    mmap2(NULL, 78547, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f47000
    close(3)                                = 0
    access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
    open("/lib/tls/i686/cmov/libc.so.6", O_RDONLY) = 3
    read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\240O\1"..., 512) = 512
    fstat64(3, {st_mode=S_IFREG|0755, st_size=1241392, ...}) = 0
    mmap2(NULL, 1247388, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7e16000
    mmap2(0xb7f3d000, 28672, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x127) = 0xb7f3d000
    mmap2(0xb7f44000, 10396, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7f44000
    close(3)                                = 0
    mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7e15000
    mprotect(0xb7f3d000, 20480, PROT_READ)  = 0
    set_thread_area({entry_number:-1 -> 6, base_addr:0xb7e156c0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
    munmap(0xb7f47000, 78547)               = 0
    mmap2(NULL, 2000003072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory)
    brk(0)                                  = 0x804a000
    brk(0x7f3c4000)                         = 0x804a000
    mmap2(NULL, 2000134144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory)
    mmap2(NULL, 2097152, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0xb7c15000
    munmap(0xb7c15000, 962560)              = 0
    munmap(0xb7e00000, 86016)               = 0
    mprotect(0xb7d00000, 135168, PROT_READ|PROT_WRITE) = 0
    mmap2(NULL, 2000003072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory)
    fstat64(1, {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 3), ...}) = 0
    ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfa70118) = -1 ENOTTY (Inappropriate ioctl for device)
    mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f5a000
    write(1, "-1\n", 3)                     = 3
    munmap(0xb7f5a000, 4096)                = 0
    exit_group(0)                           = ?
    Process 6984 detached

The same program correctly prints "5" on my desktop, and here is the
strace:

    execve("./a.out", ["./a.out"], [/* 91 vars */]) = 0
    uname({sys="Linux", node="reincarnation", ...}) = 0
    brk(0)                                  = 0x804a000
    access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
    mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f80000
    access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
    open("/etc/ld.so.cache", O_RDONLY)      = 3
    fstat64(3, {st_mode=S_IFREG|0644, st_size=84156, ...}) = 0
    mmap2(NULL, 84156, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f6b000
    close(3)                                = 0
    access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
    open("/lib/tls/i686/cmov/libc.so.6", O_RDONLY) = 3
    read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\240O\1"..., 512) = 512
    fstat64(3, {st_mode=S_IFREG|0755, st_size=1241392, ...}) = 0
    mmap2(NULL, 1247388, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7e3a000
    mmap2(0xb7f61000, 28672, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x127) = 0xb7f61000
    mmap2(0xb7f68000, 10396, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7f68000
    close(3)                                = 0
    mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7e39000
    mprotect(0xb7f61000, 20480, PROT_READ)  = 0
    set_thread_area({entry_number:-1 -> 6, base_addr:0xb7e398e0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
    munmap(0xb7f6b000, 84156)               = 0
    mmap2(NULL, 2000003072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40adf000
    munmap(0x40adf000, 2000003072)          = 0
    fstat64(1, {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 3), ...}) = 0
    ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbf892e80) = -1 ENOTTY (Inappropriate ioctl for device)
    mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f7f000
    write(1, "5\n", 2)                      = 2
    munmap(0xb7f7f000, 4096)                = 0
    exit_group(0)                           = ?
    Process 5022 detached

The difference seems to be whether the call to mmap2 after the
call to set_thread_area succeeds.  It seems that glibc is trying
to allocate almost 2G of memory in order to print into a 256-byte
buffer, and there is not enough address space for the allocation.
(My laptop kernel (custom 2.6.16) config sets CONFIG_NOHIGHMEM=y and
CONFIG_VMSPLIT_3G=y, whereas my desktop kernel (another custom 2.6.16)
sets CONFIG_HIGHMEM4G=y and CONFIG_VMSPLIT_3G=y.)

Thanks,
	Ken

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16
Locale: LANG=zh_TW.UTF-8, LC_CTYPE=zh_TW.UTF-8 (charmap=UTF-8)

Versions of packages libc6 depends on:
ii  tzdata                        2006g-2    Time Zone and Daylight Saving Time

libc6 recommends no packages.

-- no debconf information

-- 
Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
I find it funny how the more interesting something is to me
the harder it is for me to think of a use for it. -- A post on Ars Technica

Attachment: signature.asc
Description: Digital signature


--- End Message ---
--- Begin Message ---
Source: glibc
Source-Version: 2.5-6

We believe that the bug you reported is fixed in the latest version of
glibc, which is due to be installed in the Debian FTP archive:

glibc-doc_2.5-6_all.deb
  to pool/main/g/glibc/glibc-doc_2.5-6_all.deb
glibc_2.5-6.diff.gz
  to pool/main/g/glibc/glibc_2.5-6.diff.gz
glibc_2.5-6.dsc
  to pool/main/g/glibc/glibc_2.5-6.dsc
libc6-dbg_2.5-6_amd64.deb
  to pool/main/g/glibc/libc6-dbg_2.5-6_amd64.deb
libc6-dev-i386_2.5-6_amd64.deb
  to pool/main/g/glibc/libc6-dev-i386_2.5-6_amd64.deb
libc6-dev_2.5-6_amd64.deb
  to pool/main/g/glibc/libc6-dev_2.5-6_amd64.deb
libc6-i386_2.5-6_amd64.deb
  to pool/main/g/glibc/libc6-i386_2.5-6_amd64.deb
libc6-pic_2.5-6_amd64.deb
  to pool/main/g/glibc/libc6-pic_2.5-6_amd64.deb
libc6-prof_2.5-6_amd64.deb
  to pool/main/g/glibc/libc6-prof_2.5-6_amd64.deb
libc6-udeb_2.5-6_amd64.udeb
  to pool/main/g/glibc/libc6-udeb_2.5-6_amd64.udeb
libc6_2.5-6_amd64.deb
  to pool/main/g/glibc/libc6_2.5-6_amd64.deb
libnss-dns-udeb_2.5-6_amd64.udeb
  to pool/main/g/glibc/libnss-dns-udeb_2.5-6_amd64.udeb
libnss-files-udeb_2.5-6_amd64.udeb
  to pool/main/g/glibc/libnss-files-udeb_2.5-6_amd64.udeb
locales-all_2.5-6_amd64.deb
  to pool/main/g/glibc/locales-all_2.5-6_amd64.deb
locales_2.5-6_all.deb
  to pool/main/g/glibc/locales_2.5-6_all.deb
nscd_2.5-6_amd64.deb
  to pool/main/g/glibc/nscd_2.5-6_amd64.deb



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 421555@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Aurelien Jarno <aurel32@debian.org> (supplier of updated glibc package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.7
Date: Mon, 07 May 2007 03:27:10 +0200
Source: glibc
Binary: libc0.1-prof libc6-dev-amd64 locales-all libc6-i686 libc6-dev-ppc64 libc0.3-pic glibc-doc libc0.3 libc6-dev-mipsn32 libc0.1-i686 libc0.1-i386 libc6-mips64 libc6.1-dev libc6-s390x libnss-files-udeb libc0.1-dev-i386 libc6-dev-sparc64 libc6-i386 libc0.3-dev libc6-udeb libc6-dbg libc6.1-pic libc6-dev libc0.3-prof libc6-sparcv9 libc0.1-udeb libc6-dev-i386 libc6.1-prof libc6-mipsn32 libc0.1-dev locales libc6-pic libc0.3-udeb libc6-dev-powerpc libc0.1-pic libc6-ppc64 libc0.3-dbg libc0.1-dbg libc6-amd64 libc0.1 libc6-prof libc6-xen libc6-dev-mips64 libc6-powerpc libc6 libc6-sparcv9b libc6.1-udeb libc6.1-dbg nscd libc6-sparc64 libnss-dns-udeb libc6.1 libc6-dev-s390x
Architecture: source amd64 all
Version: 2.5-6
Distribution: unstable
Urgency: low
Maintainer: Aurelien Jarno <aurel32@debian.org>
Changed-By: Aurelien Jarno <aurel32@debian.org>
Description: 
 glibc-doc  - GNU C Library: Documentation
 libc6      - GNU C Library: Shared libraries
 libc6-dbg  - GNU C Library: Libraries with debugging symbols
 libc6-dev  - GNU C Library: Development Libraries and Header Files
 libc6-dev-i386 - GNU C Library: 32bit development libraries for AMD64
 libc6-i386 - GNU C Library: 32bit shared libraries for AMD64
 libc6-pic  - GNU C Library: PIC archive library
 libc6-prof - GNU C Library: Profiling Libraries
 libc6-udeb - GNU C Library: Shared libraries - udeb (udeb)
 libnss-dns-udeb - GNU C Library: NSS helper for DNS - udeb (udeb)
 libnss-files-udeb - GNU C Library: NSS helper for files - udeb (udeb)
 locales    - GNU C Library: National Language (locale) data [support]
 locales-all - GNU C Library: Precompiled locale data
 nscd       - GNU C Library: Name Service Cache Daemon
Closes: 380195 421555 421882 422067
Changes: 
 glibc (2.5-6) unstable; urgency=low
 .
   * patches/any/cvs-vfprintf-stack-smashing.diff: new patch from
     upstream (fix enormous alloca triggered with %-X.Ys like formats
     specifier, with Y big, and in multi-byte locales). Closes: #380195,
     #421555.
   * patches/hppa/cvs-hppa-update.diff: update from CVS to fix
     bits/pthreadtypes.h on hppa.
   * patches/any/local-disable-nscd-host-caching.diff: the comment lines
     should have the '#' on the first column.  Closes: #421882.
   * Remove patches/any/local-Rminkernel.diff (not needed anymore).
   * debian/patches/hppa/submitted-ustat.diff: new patch from Jeff Bailey
     to makes glibc build with exported kernel headers.
   * debian/patches/hppa/submitted-nptl-carlos2.diff: new patch to add
     STACK_GROWS_UP case to NPTL.
   * debian/patches/hppa/local-r19use.diff: new patch from Carlos O'Donell
     (specify r19 as input to asms that save/restore).
   * debian/patches/alpha/cvs-cfi.diff: new patch from CVS (fix
     cfi instructions in sysdep-cancel.h).  Closes: #422067.
   * debian/sysdeps/kfreebsd-i386.mk: tune for i686.
   * debian/sysdeps/i386.mk: drop i386-linux-gnu compat symlinks, all the
     toolchain is now using i486-linux-gnu.
   * Merge from multiarch tree:
     - debian/rules: define localedir, sysconfdir and rootsbindir.
     - debian/rules.d/build.mk: use $(localedir), $(sysconfdir) and
       $(rootsbindir) instead of hardcoded values. Make includedir
       flavour specific.
     - debian/sysdeps/amd64.mk: define i386_includedir.
     - debian/sysdeps/powerpc.mk: define ppc64_includedir.
     - debian/sysdeps/ppc64.mk: define powerpc_includedir.
     - debian/sysdeps/s390.mk: define s390x_includedir.
     - debian/sysdeps/kfreebsd-amd64.mk: define i386_includedir.
     - debian/sysdeps/sparc.mk: define sparc64_includedir.
   * debian/control.in/main: build-depends on gcc-4.1.2 (>= 4.1.2-6) on
     hppa.
Files: 
 291190b834d6ac3d0de2fdb3ec2ea649 2357 libs required glibc_2.5-6.dsc
 29a4e5c7eea7240b51df0db249944e4d 1131999 libs required glibc_2.5-6.diff.gz
 f63228bdd7d0357d291fc0c18b26dba6 1606514 doc optional glibc-doc_2.5-6_all.deb
 e171eba8baad9c733d2669a2733aaade 4083322 libs standard locales_2.5-6_all.deb
 c1e61b5912747ec741f105c5c0c99f1b 4889944 libs required libc6_2.5-6_amd64.deb
 7d0372979d4a3516d996dc5cff950d06 2471874 libdevel optional libc6-dev_2.5-6_amd64.deb
 2d1b55dfb1dcf9ffb9133b05818e9e47 1909502 libdevel extra libc6-prof_2.5-6_amd64.deb
 10561eb21fc39a52a8743ccaab3160e5 1453092 libdevel optional libc6-pic_2.5-6_amd64.deb
 2a57431fae30bd41f6469fe01cecb1ca 1953042 libs extra locales-all_2.5-6_amd64.deb
 f0a7398313004d3a5ebda23c6233dfa4 3691506 libs optional libc6-i386_2.5-6_amd64.deb
 0b4ff51a714ac02c2104c8db65c6faa4 1858844 libdevel optional libc6-dev-i386_2.5-6_amd64.deb
 e482c92700a8b54304d06fbc907dd29b 155952 admin optional nscd_2.5-6_amd64.deb
 bab976977b2f325d4df3f814f1791405 5080458 libdevel extra libc6-dbg_2.5-6_amd64.deb
 0b70957a0cd5c72fbc363865da7187c4 1101896 debian-installer extra libc6-udeb_2.5-6_amd64.udeb
 184ea99bad580fe0c2add859b98b3959 9506 debian-installer extra libnss-dns-udeb_2.5-6_amd64.udeb
 56a22cadd28acf2446598d83b18b2550 17772 debian-installer extra libnss-files-udeb_2.5-6_amd64.udeb
Package-Type: udeb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGPswNw3ao2vG823MRAjZDAKCDzHp7fx2XDxuwgv7um+mz0x1feQCfTX5D
lwG7GdklF8UpCJ+R36TBmrI=
=GlVm
-----END PGP SIGNATURE-----


--- End Message ---

Reply to: