public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "geir at cray dot com" <sourceware-bugzilla@sourceware.org> 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. Date: Mon, 14 Feb 2011 23:32:00 -0000 [thread overview] Message-ID: <bug-12491-131@http.sourceware.org/bugzilla/> (raw) 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 <sys/types.h> #include <stdio.h> #include <pwd.h> 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.
next reply other threads:[~2011-02-14 23:32 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-02-14 23:32 geir at cray dot com [this message] 2011-03-04 23:55 ` [Bug libc/12491] " geir at cray dot com 2011-04-18 2:26 ` drepper.fsp at gmail dot com 2011-09-15 16:15 ` geir at cray dot com 2014-06-27 13:51 ` fweimer at redhat dot com 2021-09-12 16:46 ` ovilewade9 at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-12491-131@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sources.redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).