RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1085549 - glibc: [RFE][LLNL 7.4 Bug] ldd misreports error
Summary: glibc: [RFE][LLNL 7.4 Bug] ldd misreports error
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: glibc
Version: 8.1
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: pre-dev-freeze
: 8.1
Assignee: glibc team
QA Contact: qe-baseos-tools-bugs
URL:
Whiteboard:
: 1817111 (view as bug list)
Depends On:
Blocks: 1599298
TreeView+ depends on / blocked
 
Reported: 2014-04-08 22:07 UTC by Ben Woodard
Modified: 2023-11-16 04:25 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-05-14 19:59:53 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
bz1085549.diff (1.61 KB, patch)
2014-04-08 22:49 UTC, Carlos O'Donell
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Sourceware 24150 0 P3 REOPENED ldd should print "not a dynamic executable" to standard error 2021-02-18 06:56:07 UTC
Sourceware 25991 0 P2 NEW ldd should print "insufficient memory" in certain cases 2021-02-18 06:56:07 UTC

Description Ben Woodard 2014-04-08 22:07:12 UTC
Description of problem:
if ldd fails for any reason including limited memory, the error message printed is "not a dynamic executable" which is not necessarily the real problem


Version-Release number of selected component (if applicable):
6.4 but appears to be all 

How reproducible:
always with the right setup

Steps to Reproduce:
severely limit memory and try to run ldd on a big executable

Actual results:
not a dynamic executable

Expected results:
it prints out that the reason it can't complete is lack of memory

Additional info:
ldd is just a script and the failing executable is actually ld-linux.
When you look at ld-linux it is exiting with EXIT_FAILURE (1) which causes that message to be in error.

in the case where it is out of memory, we might want to return something other than 1 like 3 and use that in the ldd script. 2 is already taken.

the challenge seems to be reporting what the actual error is from the kernel to glibc. That is down in the __dl_catch_error code. It seems to be called when something goes wrong in the dl linking by the elf handler in the kernel. 

I don't see where it sets any value that could be gleaned to figure out the actual source of the error.

Comment 2 Carlos O'Donell 2014-04-08 22:28:15 UTC
(In reply to Ben Woodard from comment #0)
> I don't see where it sets any value that could be gleaned to figure out the
> actual source of the error.

We need a reduced test case that shows the problem.

On glibc 2.17 or newer I see the following:

[carlos@koi ~]$ ulimit -v 5000
[carlos@koi ~]$ /usr/bin/ldd /lib64/libc.so.6
/usr/bin/bash: error while loading shared libraries: libdl.so.2: failed to map segment from shared object: Cannot allocate memory

Which looks exactly like what I would expect.

Thus this will get fixed as our users upgrade to the next version of RHEL.

To answer your technical question, glibc uses setjmp/longjmp around dlopen to handle errors and the error code returned is the error returned by the kernel and reported to the user. We are already propagating this errors for ENOMEM and passing that up via _dl_signal_error.

There might be a case we missed?

Comment 3 Carlos O'Donell 2014-04-08 22:30:56 UTC
Oh, hrm, I wonder if the latter failure was not in ldd, but in ld.so getting reach to run itself...

Comment 4 Carlos O'Donell 2014-04-08 22:31:28 UTC
(In reply to Carlos O'Donell from comment #3)
> Oh, hrm, I wonder if the latter failure was not in ldd, but in ld.so getting
> reach to run itself...

Either way, we need a test case.

Comment 5 Carlos O'Donell 2014-04-08 22:49:35 UTC
Created attachment 884276 [details]
bz1085549.diff

Comment 6 Ben Woodard 2014-04-09 00:53:36 UTC
I like your patch, I think it will solve the problem. I was looking in the same location but got misled by the "continuable error" part in the comment preceding _dl_signal_error and didn't recognize it as the entry point which stashed away the error code. I was looking for some other "non-continuable" error that could also jump into _dl_catch_error and kind of got lost.

I don't know how to make a test that would be reproducible across all possible platforms. The original bug report wasn't with ulimit: 

"A user on aztec3 had a process which top(1) showed to be consuming 91.8%
of memory. Meanwhile another user was trying to run a simple dynamically built serial code and file(1) on the executable said:

<executable>: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped

but ldd(1) said in the same 10-second period:

        not a dynamic executable

which was false information, and there was no error message such as,

"Could not load the executable to review its shared objects", or
some such. can we please get some [useful] error messages out of this?

----

I could probably reproduce it in virtual machine or maybe with a cgroup container but I don't know exactly how to make a very linux specific platform.

Comment 7 Ben Woodard 2014-04-09 00:55:53 UTC
err garbled my last comment: 
I could probably reproduce it in virtual machine or maybe with a cgroup container but I don't know exactly how to make a general reproducer like what is in the test suite both virtual machines and containers are very specific to the RHEL platform.

Comment 8 Carlos O'Donell 2014-04-10 07:43:34 UTC
(In reply to Ben Woodard from comment #7)
> err garbled my last comment: 
> I could probably reproduce it in virtual machine or maybe with a cgroup
> container but I don't know exactly how to make a general reproducer like
> what is in the test suite both virtual machines and containers are very
> specific to the RHEL platform.

Use systemtap and inject a NULL return for mmmap.

See:
https://sourceware.org/glibc/wiki/Testing/WhiteBox

Comment 11 Carlos O'Donell 2015-01-07 03:22:22 UTC
I've moved this to rhel-7.2. While it's possible we could have tackled this in rhel-6, I just don't see the customer demand for the change. The tricky part is that ld.so has to return new error codes, and we want to be conservative about that in rhel-6, thus the move to rhel-7.2.

Comment 18 Florian Weimer 2019-10-15 14:48:26 UTC
Upstream commit:

commit e7c8ffe4ec059da1523c093d6a240cd87d154df2
Author: Florian Weimer <fweimer>
Date:   Tue Oct 15 16:41:51 2019 +0200

    ldd: Print "not a dynamic executable" on standard error [BZ #24150]
    
    Tested with the testsuite on x86_64-linux-gnu, and manually.

Comment 19 Carlos O'Donell 2020-03-28 02:55:52 UTC
*** Bug 1817111 has been marked as a duplicate of this bug. ***

Comment 21 Carlos O'Donell 2020-05-14 19:59:53 UTC
We are actively tracking this issue upstream here:

Bug 25991 - ldd should print "insufficient memory" in certain cases
https://sourceware.org/bugzilla/show_bug.cgi?id=25991

When we make upstream progress on the bug we can review the CLOSED/UPSTREAM bugs and reopen for backport consideration.

Comment 22 Red Hat Bugzilla 2023-11-16 04:25:02 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 120 days


Note You need to log in before you can comment on or make changes to this bug.