Subject: bug#14463: closed (Re: bug#14463: coreutils-8.21 darwin regressions)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 13 Nov 2013 15:58:06 +0000

Your bug report

#14463: coreutils-8.21 darwin regressions

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
14463: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14463
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#14463: coreutils-8.21 darwin regressions
From: Paul Eggert <[email-masked]>
To: Jack Howarth <[email-masked]>
Cc: Gnulib bugs <[email-masked]>, [email-masked]
Date: Wed, 13 Nov 2013 07:57:28 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Thanks, I pushed the following patch to gnulib.  It should be
incorporated automatically into the next version of coreutils
so I'm marking the bug as done.

diff --git a/ChangeLog b/ChangeLog
index 59de3e5..aae8c64 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-11-13  Paul Eggert  <[email-masked]>
+
+	* lib/getgroups.c (posix_getgroups, getgroups) [__APPLE__]:
+	New function and macro, to work around _DARWIN_C_SOURCE problem.
+	Reported by Jack Howarth in <http://bugs.gnu.org/14463>.
+
 2013-11-11  Pádraig Brady <[email-masked]>
 
 	base64: provide a fast path for encoding well sized buffers
diff --git a/lib/getgroups.c b/lib/getgroups.c
index e71b543..482b24a 100644
--- a/lib/getgroups.c
+++ b/lib/getgroups.c
@@ -43,6 +43,21 @@ getgroups (int n _GL_UNUSED, GETGROUPS_T *groups _GL_UNUSED)
 #  define GETGROUPS_ZERO_BUG 0
 # endif
 
+/* On OS X 10.6 and later, use the usual getgroups, not the one
+   supplied when _DARWIN_C_SOURCE is defined.  _DARWIN_C_SOURCE is
+   normally defined, since it means "conform to POSIX, but add
+   non-POSIX extensions even if that violates the POSIX namespace
+   rules", which is what we normally want.  But with getgroups there
+   is an inconsistency, and _DARWIN_C_SOURCE means "change getgroups()
+   so that it no longer works right".  The BUGS section of compat(5)
+   says that the behavior is dubious if you compile different sections
+   of a program with different _DARWIN_C_SOURCE settings, so fix only
+   the offending symbol.  */
+# ifdef __APPLE__
+int posix_getgroups (int, gid_t []) __asm ("_getgroups");
+#  define getgroups posix_getgroups
+# endif
+
 /* On at least Ultrix 4.3 and NextStep 3.2, getgroups (0, NULL) always
    fails.  On other systems, it returns the number of supplemental
    groups for the process.  This function handles that special case

Subject: coreutils-8.21 darwin regressions
From: Jack Howarth <[email-masked]>
To: [email-masked]
Date: Fri, 24 May 2013 09:09:51 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

   I am finding on x86_64-apple-darwin12 that coreutils 8.21 exhibits four additional failures in gnulib-tests
which aren't present in a build of coreutils 8.19. These are...

FAIL: test-getcwd.sh
FAIL: test-getgroups
FAIL: test-getlogin
FAIL: test-vasprintf-posix

The respective logs shows...

FAIL: test-getcwd.sh (exit: 7)
==============================

FAIL: test-getgroups (exit: 134)
================================

test-getgroups.c:58: assertion failed

FAIL: test-getlogin (exit: 134)
===============================

test-getlogin.c:69: assertion failed

FAIL: test-vasprintf-posix (exit: 134)
======================================

test-vasprintf-posix.c:238: assertion failed

These trace in gdb as...

# gdb ./test-getgroups
GNU gdb 6.3.50-20050815 (Apple version gdb-1824) (Wed Feb  6 22:51:23 UTC 2013)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries .. done

(gdb) break main
Breakpoint 1 at 0x1000014a7: file test-getgroups.c, line 39.
(gdb) r
Starting program: /sw/src/fink.build/coreutils-8.21-100/coreutils-8.21/gnulib-tests/test-getgroups 
Reading symbols for shared libraries +............................. done

Breakpoint 1, main (argc=1, argv=0x7fff5fbff7a0) at test-getgroups.c:39
39	  errno = 0;
(gdb) s
40	  result = getgroups (0, NULL);
(gdb) 
rpl_getgroups (n=0, group=0x0) at getgroups.c:70
70	        return getgroups (n, (GETGROUPS_T *) group);
(gdb) 
Current language:  auto; currently minimal
0x0000000100001cfc in dyld_stub_getgroups$DARWIN_EXTSN ()
(gdb) 
Single stepping until exit from function dyld_stub_getgroups$DARWIN_EXTSN, 
which has no line number information.
test-getgroups.c:58: assertion failed

Program received signal SIGABRT, Aborted.
0x00007fff885b4d46 in __kill ()
(gdb) 

# gdb ./test-getlogin
GNU gdb 6.3.50-20050815 (Apple version gdb-1824) (Wed Feb  6 22:51:23 UTC 2013)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries .. done

(gdb) break main
Breakpoint 1 at 0x100000894: file test-getlogin.c, line 39.
(gdb) r
Starting program: /sw/src/fink.build/coreutils-8.21-100/coreutils-8.21/gnulib-tests/test-getlogin 
Reading symbols for shared libraries +............................. done

Breakpoint 1, main () at test-getlogin.c:39
39	  buf = getlogin ();
(gdb) s
40	  if (buf == NULL)
(gdb) s
65	    const char *name = getenv ("LOGNAME");
(gdb) s
66	    if (name == NULL || name[0] == '\0')
(gdb) s
68	    if (name != NULL && name[0] != '\0')
(gdb) s
69	      ASSERT (strcmp (buf, name) == 0);
(gdb) s
test-getlogin.c:69: assertion failed
rpl_fflush (stream=0x7fff76c23bc0) at fflush.c:145
145	  if (stream == NULL || ! freading (stream))
(gdb) s
Current language:  auto; currently minimal
freading (fp=0x7fff76c23bc0) at freading.c:39
39	  return (fp_->_flags & __SRD) != 0;
(gdb) s
rpl_fflush (stream=0x7fff76c23bc0) at fflush.c:146
146	    return fflush (stream);
(gdb) s
0x0000000100000cd2 in dyld_stub_fflush ()
(gdb) s
Single stepping until exit from function dyld_stub_fflush, 
which has no line number information.

Program received signal SIGABRT, Aborted.
0x00007fff885b4d46 in __kill ()
(gdb) 

The full trace for the test-vasprintf-posix test case is rather large and is attached as a gzip file.
         Jack