public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "carlos at redhat dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug dynamic-link/25991] New: ldd should print "insufficient memory" in certain cases Date: Thu, 14 May 2020 14:33:28 +0000 [thread overview] Message-ID: <bug-25991-131@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=25991 Bug ID: 25991 Summary: ldd should print "insufficient memory" in certain cases Product: glibc Version: 2.29 Status: NEW Severity: normal Priority: P2 Component: dynamic-link Assignee: unassigned at sourceware dot org Reporter: carlos at redhat dot com Target Milestone: --- The dynamic loader when used as ldd, and when it runs out of memory, should return a unique error code that causes ldd to print "insufficient memory" in those cases. For example: diff --git a/elf/ldd.bash.in b/elf/ldd.bash.in index 4ff140d..6c1144c 100644 --- a/elf/ldd.bash.in +++ b/elf/ldd.bash.in @@ -186,6 +186,9 @@ warning: you do not have execution permission for" "\`$file'" >&2 2) try_trace "$RTLD" "$file" || result=1 ;; + 3) + echo 'ldd:' ${RTLD} $" insufficient memory" >&2 + ;; *) echo 'ldd:' ${RTLD} $"exited with unknown exit code" "($ret)" >&2 exit 1 diff --git a/elf/rtld.c b/elf/rtld.c index 9d121dc..90b8ab7 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -44,6 +44,9 @@ #include <assert.h> +/* Exit with a value of 3 if we ran out of memory while tracing. */ +#define EXIT_ENOMEM 3 + /* Avoid PLT use for our local calls at startup. */ extern __typeof (__mempcpy) __mempcpy attribute_hidden; @@ -1060,18 +1063,23 @@ of this helper program; chances are you did not intend to run this program.\n\ { const char *objname; const char *err_str = NULL; + int errcode; struct map_args args; bool malloced; args.str = rtld_progname; args.loader = NULL; args.mode = __RTLD_OPENEXEC; - (void) _dl_catch_error (&objname, &err_str, &malloced, map_doit, - &args); + errcode = _dl_catch_error (&objname, &err_str, &malloced, map_doit, + &args); if (__glibc_unlikely (err_str != NULL)) - /* We don't free the returned string, the programs stops - anyway. */ - _exit (EXIT_FAILURE); + { + /* We don't free the returned string, the programs stops + anyway. */ + if (errcode == ENOMEM) + _exit (EXIT_ENOMEM); + _exit (EXIT_FAILURE); + } } else { -- You are receiving this mail because: You are on the CC list for the bug.
reply other threads:[~2020-05-14 14:33 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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-25991-131@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.org \ /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).