mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Cc: Rich Felker <dalias@aerifal.cx>,
	musl@lists.openwall.com, Isaac Dunham <idunham@lavabit.com>
Subject: Re: musl, printf out-of-memory test
Date: Tue, 19 Jun 2012 12:45:50 +0200	[thread overview]
Message-ID: <5041927.IR2Ri05J2P@linuix> (raw)
In-Reply-To: <20120619001156.GJ163@brightrain.aerifal.cx>

Rich Felker wrote:
> > Replacements of *printf, because of
> > [...]
> >   checking whether printf survives out-of-memory conditions... no
> 
> No idea. Copying out the test and running it directly, it passes just
> fine for me. Maybe gnulib has already replaced printf with its own
> malloc-using version by the time it gets to this test??

Strange indeed. With a testdir of all of gnulib, I got

  configure:17615: checking whether printf survives out-of-memory conditions
  configure:17786: /arch/x86-linux/inst-musl/bin/musl-gcc -std=gnu99 -o conftest -g -O2 -Wall  conftest.c  >&5
  configure:17789: $? = 0
  configure:17837: result: yes

but with a testdir of only the POSIX related modules of gnulib, I got

  configure:13657: checking whether printf survives out-of-memory conditions
  configure:13828: /arch/x86-linux/inst-musl/bin/musl-gcc -std=gnu99 -o conftest -g -O2 -Wall  conftest.c  >&5
  configure:13831: $? = 0
  configure:13879: result: no

The '$? = 0' line prints only the linker's exit code, not the runtime
exit code. I'm adding a second output line for the runtime exit code.
Then I get:

  configure:8919: checking whether printf survives out-of-memory conditions
  configure:9090: /arch/x86-linux/inst-musl/bin/musl-gcc -o conftest -g -O2 -Wall  conftest.c  >&5
  configure:9093: $? = 0
  configure:9097: $? = 1
  configure:9142: result: no

After adding a printf to stderr: Once I get

  configure:8919: checking whether printf survives out-of-memory conditions
  configure:9093: /arch/x86-linux/inst-musl/bin/musl-gcc -o conftest -g -O2 -Wall  conftest.c  >&5
  configure:9096: $? = 0
  printf's return value = 5000002, errno = 0
  configure:9100: $? = 0
  configure:9145: result: yes

In another configure run I get:

  configure:8919: checking whether printf survives out-of-memory conditions
  configure:9093: /arch/x86-linux/inst-musl/bin/musl-gcc -o conftest -g -O2 -Wall  conftest.c  >&5
  configure:9096: $? = 0
  configure:9100: $? = 1
  configure:9145: result: no

So, the exit code 1 must have come from the crash handler. Without this crash
handler: 7x I get

  configure:8919: checking whether printf survives out-of-memory conditions
  configure:8979: /arch/x86-linux/inst-musl/bin/musl-gcc -o conftest -g -O2 -Wall  conftest.c  >&5
  configure:8982: $? = 0
  printf's return value = 5000002, errno = 0
  configure:8986: $? = 0
  configure:9031: result: yes

but once I get

  configure:8979: /arch/x86-linux/inst-musl/bin/musl-gcc -o conftest -g -O2 -Wall  conftest.c  >&5
  configure:8982: $? = 0
  configure:8986: $? = 139
  configure:9031: result: no

So, apparently, under memory stress, musl's printf has a probability of
between 10% and 50% of crashing with SIGSEGV (139 = 128 + 11).

Bruno


2012-06-19  Bruno Haible  <bruno@clisp.org>

	*printf-posix: Put more info into config.log.
	* m4/printf.m4 (gl_PRINTF_ENOMEM): Emit conftest's error output and
	exit code into config.log.

--- m4/printf.m4.orig	Tue Jun 19 12:41:56 2012
+++ m4/printf.m4	Tue Jun 19 12:41:53 2012
@@ -1,4 +1,4 @@
-# printf.m4 serial 48
+# printf.m4 serial 49
 dnl Copyright (C) 2003, 2007-2012 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -1028,8 +1028,9 @@
 changequote([,])dnl
           ])])
           if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
-            (./conftest
+            (./conftest 2>&AS_MESSAGE_LOG_FD
              result=$?
+             _AS_ECHO_LOG([\$? = $result])
              if test $result != 0 && test $result != 77; then result=1; fi
              exit $result
             ) >/dev/null 2>/dev/null



  parent reply	other threads:[~2012-06-19 10:45 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20120609230541.47eac2de@newbook>
     [not found] ` <4FD55156.7050302@cs.ucla.edu>
     [not found]   ` <20120611182202.1ee4d019@newbook>
2012-06-17 22:49     ` musl bugs found through gnulib Bruno Haible
2012-06-17 23:54       ` Rich Felker
2012-06-18  8:21         ` Szabolcs Nagy
2012-06-18 13:02           ` John Spencer
2012-06-18 14:55             ` Rich Felker
2012-06-18 15:26               ` Szabolcs Nagy
2012-06-18 16:00                 ` Rich Felker
2012-06-19 13:26               ` John Spencer
2012-06-18  0:16       ` [musl] " idunham
2012-06-19  0:11       ` Rich Felker
2012-06-19  2:07         ` [musl] " Eric Blake
2012-06-19  2:52           ` Rich Felker
2012-06-19 11:03             ` musl, fdopen test Bruno Haible
2012-06-19 11:09               ` Jim Meyering
2012-06-20 20:52                 ` Bruno Haible
2012-06-19 10:45         ` Bruno Haible [this message]
2012-06-19 19:16           ` Re: musl, printf out-of-memory test Rich Felker
2012-06-19 20:04             ` Bruno Haible
2012-06-19 20:08               ` Rich Felker
2012-06-19 21:17                 ` Bruno Haible
2012-06-20  1:52                   ` Rich Felker
2012-06-20  7:30                     ` Szabolcs Nagy
2012-06-20  9:35                     ` Bruno Haible
2012-06-20 11:00                       ` Jim Meyering
2012-06-21 19:58                         ` Tom Tromey
2012-06-20  3:04       ` Re: musl bugs found through gnulib Rich Felker
2012-06-20  4:10         ` [musl] " Eric Blake
2012-06-20 13:27           ` Rich Felker
2012-06-20  7:32         ` Szabolcs Nagy
2012-06-22 10:39         ` grantpt test Bruno Haible
2012-07-02 22:33         ` [musl] Re: musl bugs found through gnulib Pádraig Brady
2012-06-20 19:28       ` Rich Felker
2012-06-21  2:21         ` Rich Felker
2012-06-21  8:52           ` [musl] " Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5041927.IR2Ri05J2P@linuix \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    --cc=dalias@aerifal.cx \
    --cc=idunham@lavabit.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).