Subject: Re: toolchain/37143: nbmtree dumps core
To: None <jnemeth@NetBSD.org, gnats-admin@netbsd.org,>
From: John Nemeth <jnemeth@victoria.tc.ca>
List: netbsd-bugs
Date: 10/18/2007 12:35:02
The following reply was made to PR toolchain/37143; it has been noted by GNATS.

From: jnemeth@victoria.tc.ca (John Nemeth)
To: gnats-bugs@NetBSD.org, toolchain-manager@NetBSD.org,
	netbsd-bugs@NetBSD.org
Cc: 
Subject: Re: toolchain/37143: nbmtree dumps core
Date: Thu, 18 Oct 2007 05:30:09 -0700

 On Feb 2,  1:22pm, yamt@mwd.biglobe.ne.jp wrote:
 } 
 } >Number:         37143
 } >Category:       toolchain
 } >Synopsis:       nbmtree dumps core
 } >Responsible:    toolchain-manager
 } >State:          open
 } >Class:          sw-bug
 } >Arrival-Date:   Thu Oct 18 01:15:01 +0000 2007
 } >Originator:     YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
 } >Environment:
 } 	NetBSD 4.99.33 amd64
 } >Description:
 } 	it seems that nbmtree is compiled without a proper function
 } 	prototype of user_from_uid.  (-Wall yields "implicit decl" warnings)
 } 	it makes the return value truncated to int.
 } 	malloc used to return a pointer to heap, which might be small enough
 } 	to fit in int.  after jemalloc, it isn't the case anymore.
 } >How-To-Repeat:
 } 	run build.sh on 64bit -current with jemalloc.
 
      The problem is caused by this bit of code in /usr/include/pwd.h:
 
 -----
 
 #if defined(_NETBSD_SOURCE)
 int              pw_gensalt(char *, size_t, const char *, const char *);
 int              pw_scan(char *, struct passwd *, int *);
 int              setpassent(int);
 int              getpwent_r(struct passwd *, char *, size_t, struct passwd **);
 const char      *user_from_uid(uid_t, int);
 int              uid_from_user(const char *, uid_t *);
 int              pwcache_userdb(int (*)(int), void (*)(void),
                                 struct passwd * (*)(const char *),
                                 struct passwd * (*)(uid_t));
 #endif
 
 -----
 
 _NETBSD_SOURCE isn't defined for compat (i.e. tools) building.
 However, several of these functions are provided by our compat
 library.  I propose the following fix:
 
 -----
 
 #if defined(_NETBSD_SOURCE)
 int              pw_gensalt(char *, size_t, const char *, const char *);
 int              setpassent(int);
 int              getpwent_r(struct passwd *, char *, size_t, struct passwd **);
 #endif
 
 #if defined(_NETBSD_SOURCE) || defined(HAVE_NBTOOL_CONFIG_H)
 int              pw_scan(char *, struct passwd *, int *);
 const char      *user_from_uid(uid_t, int);
 int              uid_from_user(const char *, uid_t *);
 int              pwcache_userdb(int (*)(int), void (*)(void),
                                 struct passwd * (*)(const char *),
                                 struct passwd * (*)(uid_t));
 #endif
 
 -----
 
 Since I'm not famailiar with how our compat library works, I would like
 somebody else to verify that this is correct.
 
 
 }-- End of excerpt from yamt@mwd.biglobe.ne.jp