Subject: pkg/33664: glib uses unimplmented sysconf (_SC_GETPW_R_SIZE_MAX) on darwin
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: Darrin B.Jewell <dbj@netbsd.org>
List: pkgsrc-bugs
Date: 06/07/2006 19:50:00
>Number:         33664
>Category:       pkg
>Synopsis:       glib uses unimplmented sysconf (_SC_GETPW_R_SIZE_MAX) on darwin
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 07 19:50:00 +0000 2006
>Originator:     Darrin B. Jewell
>Release:        pkgsrc-2006Q1 branch updated via cvs ~20060605T1828Z
>Organization:
>Environment:

$ uname -a
Darwin Quiteria 8.6.0 Darwin Kernel Version 8.6.0: Tue Mar  7 16:58:48 PST 2006; root:xnu-792.6.70.obj~1/RELEASE_PPC Power Macintosh powerpc

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.4.6
BuildVersion:	8I127

$ powerpc-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5341)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ cat /Developer/Applications/Xcode.app/Contents/version.plist 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>BuildVersion</key>
        <string>10</string>
        <key>CFBundleShortVersionString</key>
        <string>2.3</string>
        <key>CFBundleVersion</key>
        <string>744</string>
        <key>ProjectName</key>
        <string>DevToolsIDE</string>
        <key>SourceVersion</key>
        <string>7440000</string>
</dict>
</plist>

>Description:

When building gnome-libs on darwin, the build fails with a fatal
glib error when running gnome-gen-mimedb on pkg/etc/mime-magic:

  GLib-ERROR **: could not allocate -1 bytes
  aborting...

I tracked this to an error in glib when sysconf (_SC_GETPW_R_SIZE_MAX)
returns -1.  This bug is fixed for FreeBSD in patch-af from PR 21909
However, that patch is protected by #ifdeff __FreeBSD__ and so does
fix the problem seen by Darwin.

>How-To-Repeat:

build gnome-libs on darwin

>Fix:

I propose removing the __FreeBSD__ check in patch-af since this
patch is appropriate for any system where sysconf (_SC_GETPW_R_SIZE_MAX)
returns -1 and should not affect systems that implement this call.

Index: patches/patch-af
===================================================================
RCS file: /cvsroot/pkgsrc/devel/glib/patches/patch-af,v
retrieving revision 1.5
diff -u -u -r1.5 patch-af
--- patches/patch-af	8 Feb 2004 23:22:45 -0000	1.5
+++ patches/patch-af	7 Jun 2006 18:57:52 -0000
@@ -2,13 +2,11 @@
 
 --- gutils.c.orig	2003-09-04 22:39:55.000000000 +0200
 +++ gutils.c	2003-09-04 22:41:06.000000000 +0200
-@@ -483,6 +483,9 @@
+@@ -483,6 +483,7 @@
  #    ifdef _SC_GETPW_R_SIZE_MAX  
          /* This reurns the maximum length */
          guint bufsize = sysconf (_SC_GETPW_R_SIZE_MAX);
-+#if defined(__FreeBSD__) || defined(__NetBSD__)
 +	if (bufsize == (guint) -1) bufsize = 64; /* XXX Correct for unimpelemented SC */
-+#endif  /* __FreeBSD__ */
  #    else /* _SC_GETPW_R_SIZE_MAX */
          guint bufsize = 64;
  #    endif /* _SC_GETPW_R_SIZE_MAX */