From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13564 invoked by alias); 14 Feb 2011 23:32:39 -0000 Received: (qmail 13555 invoked by uid 22791); 14 Feb 2011 23:32:38 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_PW,TW_TP,TW_WU X-Spam-Check-By: sourceware.org Received: from localhost (HELO sourceware.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 14 Feb 2011 23:32:35 +0000 From: "geir at cray dot com" To: glibc-bugs@sources.redhat.com Subject: [Bug libc/12491] New: Calling getpwuid in a statically linked program should return an error, not a seg fault. X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: geir at cray dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: drepper.fsp at gmail dot com X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Mon, 14 Feb 2011 23:32:00 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2011-02/txt/msg00037.txt.bz2 http://sourceware.org/bugzilla/show_bug.cgi?id=12491 Summary: Calling getpwuid in a statically linked program should return an error, not a seg fault. Product: glibc Version: 2.9 Status: NEW Severity: normal Priority: P2 Component: libc AssignedTo: drepper.fsp@gmail.com ReportedBy: geir@cray.com For a system that is NOT running the nscd daemon, a statically linked program that calls getpwuid will return a segmentation fault. The resulting core file does not provide much help in debugging the problem. getpwuid or the routines that it calls should be more robust and not seg fault in this situation, but rather return an error to the user. I realize that a link time warning message is shown about using getpwuid in a statically linked program, but this warning message can easily be overlooked when building a large application that has other warning messages. test case: $ cat getpwuid.c #include #include #include int main(){ int uid; struct passwd *pw; uid=getuid(); printf("UID=%d\n", uid); pw = getpwuid(uid); printf("Done.\n"); printf("Name=%s\n", pw->pw_name); return 0; } $ strings /usr/lib64/libc.a | grep -i "release version" GNU C Library stable release version 2.9 (20081117), by Roland McGrath et al. $ gcc -g -static -o getpwuid getpwuid.c /tmp/pbs.581087.sdb/ccyZpaUZ.o: In function `main': /home/users/geir/getpwuid.c:10: warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking $ ps -ale | grep nscd $ ./getpwuid UID=10682 Segmentation fault $ Here is the unhelpful traceback of the corefile: (gdb) bt #0 0x0000000000000000 in ?? () #1 0x00002aaaad4fd5dc in __pthread_initialize_minimal_internal () from /lib64/libpthread.so.0 #2 0x00002aaaad4fce49 in _init () from /lib64/libpthread.so.0 #3 0x0000000000000000 in ?? () (gdb) -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.