bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* *alloc-gnu on Solaris 11
@ 2021-05-14 17:04 Bruno Haible
  2021-05-15 14:04 ` *alloc-gnu on glibc Pádraig Brady
  0 siblings, 1 reply; 6+ messages in thread
From: Bruno Haible @ 2021-05-14 17:04 UTC (permalink / raw)
  To: bug-gnulib

On Solaris 11.3 (the machine gcc211.fsffrance.org, in 64-bit mode), there
are test failures:
  FAIL: test-calloc-gnu
  FAIL: test-malloc-gnu
  FAIL: test-realloc-gnu
  FAIL: test-reallocarray
Each of these tests takes about 30 seconds before failing, and is not
immediately reactive to Ctrl-C.

$ time ./test-malloc-gnu
errno=11=EAGAIN
../../tests/test-malloc-gnu.c:42: assertion 'errno == ENOMEM' failed
Abort (Speicherabzug geschrieben)

real    0m28,908s
user    0m0,001s
sys     0m0,012s


$ truss ./test-malloc-gnu
...
brk(0x00000000)                                 = 0x100102248
brk(0x100102250)                                = 0x00000000
brk(0x100106250)                                = 0x00000000
brk(0x100106250)                                = 0x00000000
brk(0x8000000100106240)                         Err#11 EAGAIN  ; <== this takes 30 sec
brk(0x100106250)                                = 0x00000000
...

So, two things are wrong here:
  * We should enforce an errno ENOMEM, not EAGAIN.
    1. for compliance with POSIX.
    2. for a reasonable error message.
    3. so that programs don't attempt to repeat the call and thus bring the
       system to its knees.
  * We should avoid running such a resource-consuming test as part of
    "make check".

This patch fixes the first issue and, as a side effect, the second issue as
well.


2021-05-14  Bruno Haible  <bruno@clisp.org>

	malloc-gnu, realloc-gnu, calloc-gnu: Ensure errno gets set to ENOMEM.
	* m4/malloc.m4 (gl_CHECK_MALLOC_POSIX): Set gl_cv_func_malloc_posix to
	'no' also on Solaris.

diff --git a/m4/malloc.m4 b/m4/malloc.m4
index 6fcd4ad..972e808 100644
--- a/m4/malloc.m4
+++ b/m4/malloc.m4
@@ -1,4 +1,4 @@
-# malloc.m4 serial 26
+# malloc.m4 serial 27
 dnl Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -113,7 +113,7 @@ AC_DEFUN([gl_FUNC_MALLOC_POSIX],
   fi
 ])
 
-# Test whether malloc, realloc, calloc set errno on failure.
+# Test whether malloc, realloc, calloc set errno to ENOMEM on failure.
 # Set gl_cv_func_malloc_posix to yes or no accordingly.
 AC_DEFUN([gl_CHECK_MALLOC_POSIX],
 [
@@ -129,9 +129,13 @@ AC_DEFUN([gl_CHECK_MALLOC_POSIX],
       case "$host_os" in
         mingw*)
           gl_cv_func_malloc_posix=no ;;
-        irix*)
-          dnl The three functions return NULL with errno unset when the
-          dnl argument is larger than PTRDIFF_MAX. Here is a test program:
+        irix* | solaris*)
+          dnl On IRIX 6.5, the three functions return NULL with errno unset
+          dnl when the argument is larger than PTRDIFF_MAX.
+          dnl On Solaris 11.3, the three functions return NULL with errno set
+          dnl to EAGAIN, not ENOMEM, when the argument is larger than
+          dnl PTRDIFF_MAX.
+          dnl Here is a test program:
 m4_divert_push([KILL])
 #include <errno.h>
 #include <stdio.h>



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-05-15 18:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-14 17:04 *alloc-gnu on Solaris 11 Bruno Haible
2021-05-15 14:04 ` *alloc-gnu on glibc Pádraig Brady
2021-05-15 15:36   ` Paul Eggert
2021-05-15 15:49   ` Bruno Haible
2021-05-15 17:08     ` Pádraig Brady
2021-05-15 18:07       ` Bruno Haible

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 read-only IMAP folder(s) and NNTP newsgroup(s).