Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 382241 - net-misc/curl-7.21.4 configure fail with: /bin/sh: error while loading shared libraries: /usr/lib/libncurses.so.5: invalid ELF header
Summary: net-misc/curl-7.21.4 configure fail with: /bin/sh: error while loading shared...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Christoph Mende (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-08 08:22 UTC by Alessandro Surace
Modified: 2021-07-22 03:23 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info (emerge.info,6.62 KB, text/plain)
2011-09-08 08:24 UTC, Alessandro Surace
Details
build.log (build.log,32.28 KB, text/plain)
2011-09-08 08:27 UTC, Alessandro Surace
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alessandro Surace 2011-09-08 08:22:18 UTC
Wnen I try to build curl the configure process fail with :
/bin/sh: error while loading shared libraries: /usr/lib/libncurses.so.5: invalid ELF header

Reproducible: Always

Steps to Reproduce:
1. emerge -v curl
2.
3.
Actual Results:  
checking whether to enable SSPI support (Windows native builds only)... no
checking whether to enable cryptographic authentication methods... yes
checking whether to enable TLS-SRP authentication... yes
checking whether to enable support for cookies... yes
checking whether to enable hidden symbols in the library... no
checking whether to enforce SONAME bump... no
configure: creating ./config.status
/bin/sh: error while loading shared libraries: /usr/lib/libncurses.so.5: invalid ELF header




The problem is somewhere in option used to configure curl because if I try to configure curl with default options it worlk properly.

I've searched for libncurses.so.5 revdep but no problem has been found.
Comment 1 Alessandro Surace 2011-09-08 08:24:54 UTC
Created attachment 285829 [details]
emerge --info
Comment 2 Alessandro Surace 2011-09-08 08:27:04 UTC
Created attachment 285831 [details]
build.log
Comment 3 Jeroen Roovers (RETIRED) gentoo-dev 2011-09-08 16:41:40 UTC
So did you run revdep-rebuild yet?
Comment 4 Alessandro Surace 2011-09-12 14:18:55 UTC
Already done as write in my comment...But nothing has changed
Comment 5 Mike Gilbert gentoo-dev 2011-09-16 02:31:52 UTC
Can you try it with ccache disabled?
Comment 6 Jeroen Roovers (RETIRED) gentoo-dev 2011-09-16 14:47:33 UTC
(In reply to comment #4)
> Already done as write in my comment...But nothing has changed

You wrote: "I've searched for libncurses.so.5 revdep but no problem has been found."

That is not English for "I ran revdep-rebuild." Just saying.
Comment 7 Christoph Mende (RETIRED) gentoo-dev 2011-09-17 08:45:37 UTC
(In reply to comment #0)
> The problem is somewhere in option used to configure curl because if I try to
> configure curl with default options it worlk properly.

Please define "default options" and the difference to the failing build.
Comment 8 Alessandro Surace 2011-09-17 23:32:07 UTC
(In reply to comment #7)
> (In reply to comment #0)
> > The problem is somewhere in option used to configure curl because if I try to
> > configure curl with default options it worlk properly.
> 
> Please define "default options" and the difference to the failing build.

I mean the option that are created when I run ./configure from the source.
Comment 9 Alessandro Surace 2011-09-17 23:44:16 UTC
(In reply to comment #5)
> Can you try it with ccache disabled?

Yes nothing change
Comment 10 Alessandro Surace 2011-09-17 23:52:30 UTC
These are the default options from ./configure output:

  SSL support:     enabled (OpenSSL)
  SSH support:     enabled (libSSH2)
  zlib support:    enabled
  resolver:        default (--enable-ares / --enable-threaded-resolver)
  IDN support:     enabled
  Build libcurl:   Shared=yes, Static=yes
  Built-in manual: enabled
  Verbose errors:  enabled (--disable-verbose)
  LDAP support:    enabled (OpenLDAP)
  LDAPS support:   enabled
  RTSP support:    enabled
  Protocols:       DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS LDAP LDAPS POP3 POP3S RTSP SCP SFTP SMTP SMTPS TELNET TFTP

while these are the portage options:
ares ipv6 kerberos ldap nss ssl
Comment 11 Christoph Mende (RETIRED) gentoo-dev 2011-09-23 18:25:55 UTC
please try the exact same configure options (you can get those from your build.log) and also please try 7.22
Comment 12 Alessandro Surace 2011-09-27 13:53:29 UTC
(In reply to comment #11)
> please try the exact same configure options (you can get those from your
> build.log) and also please try 7.22

Same problem with 7.22 and with the same configure options.

I've found the problem and the solution...in an HARD WAY!!!
Practically I've debugged the configure process to see where the problem was and the problem was the LD_LIBRARY_PATH ; I try to explain what happens.

In a new shell my LD_LIBRARY_PATH is /mnt/oracle/OraHome1/lib:/mnt/oracle/OraHome1/network/lib

Adding debugging to the configure script I've seen that the LD_LIBRARY_PATH was modified in:
LD_LIBRARY_PATH=/mnt/oracle/OraHome1/lib:/mnt/oracle/OraHome1/network/lib:/usr/lib

This generate the original error:
/bin/sh: error while loading shared libraries: /usr/lib/libncurses.so.5:
invalid ELF header

At this point if I set this LD_LIBRARY_PATH to a new shell I get the same error for everything linked to ncurses.
 
BUT the error occurs only then file /usr/lib/libncurses.so.5 is the GNU ld script:
/* GNU ld script
   Since Gentoo has critical dynamic libraries in /lib, and the static versions
   in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
   run into linking problems.  This "fake" dynamic lib is a linker script that
   redirects the linker to the real lib.  And yes, this works in the cross-
   compiling scenario as the sysroot-ed linker will prepend the real path.

   See bug http://bugs.gentoo.org/4411 for more info.
 */
OUTPUT_FORMAT ( elf64-x86-64 )
GROUP ( /lib64/libncurses.so.5.7 )

If I substitute the ld script file with a direct link to /lib64/libncurses.so.5.7 the problem not happens.

At the moment I'vnt find the way to build the package without error; every time the LD_LIBRARY_PATH is set although the var was initially not set.

So I think the problem is somewhere in the curl configuration process. Perhaps could be useful to assign the problem to the curl maintainer to clarify why it modifies the LD_LIBRARY_PATH and to linker team to understand because its fail to recognize the correct library.
Comment 13 Alessandro Surace 2011-09-27 14:21:37 UTC
I add some info.
If I run the configure without option the process run without error basically for 2 reason:

1) the /bin/sh ./config.status isn't called
+ echo '/bin/sh -x ./config.status  || ac_cs_success=false'
+ exec
+ :
+ test '' '!=' yes
+ ac_sub_configure_args=

2) in every case the LD_LIBRARY_PATH is not modified
Comment 14 Alessandro Surace 2011-09-28 07:51:26 UTC
I've found a WORKAROUND but it isn't THE SOLUTION!

If I set the LD_LIBRARY_PATH=/lib64 all works because after the configure however the linker search before in /lib64 where is contained the real lib.
Comment 15 Alessandro Surace 2011-09-28 12:05:18 UTC
Founded and resolved one problem.

In /usr/local I had:
-rwxr-xr-x 1 root root 527 Sep 27 16:03 libncurses.so
lrwxrwxrwx 1 root root  22 Sep 27 14:40 libncurses.so.5 -> /usr/lib/libncurses.so

With the LD_LIBRARY_PATH=/usr/lib variable exported every command fails because it parse the link libncurses.so.5 and crash:

writev(2, [{"vi", 2}, {": ", 2}, {"error while loading shared libra"..., 36}, {": ", 2}, {"/usr/lib
/libncurses.so.5", 24}, {": ", 2}, {"invalid ELF header", 18}, {"", 0}, {"", 0}, {"\n", 1}], 10vi: 
error while loading shared libraries: /usr/lib/libncurses.so.5: invalid ELF header
) = 87
exit_group(127)                         = ?


I don't know why that link doesn't like to the linker! When I remove the link /usr/lib/libncurses.so.5 everything work properly(thanks Alberto).
Comment 16 SpanKY gentoo-dev 2011-12-01 17:13:43 UTC
what does `ls -ld /usr/lib* /lib*` show ?
Comment 17 SpanKY gentoo-dev 2011-12-01 18:35:25 UTC
in the mean time, i've tweaked the 7.23.1 ebuild:
    sed -i '/LD_LIBRARY_PATH=/d' configure.ac || die #382241
Comment 18 Larry the Git Cow gentoo-dev 2021-07-22 03:23:29 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f7d7fb78e3689b5a56f384d9e0eca42ac36b23c7

commit f7d7fb78e3689b5a56f384d9e0eca42ac36b23c7
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2021-07-22 02:52:33 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2021-07-22 03:20:27 +0000

    net-misc/curl: add 7.78.0
    
    * Security bump to 7.78.0
    * Drops metalink support (gone upstream entirely)
    * Drops two obsolete seds
    
    Bug: https://bugs.gentoo.org/382241
    Bug: https://bugs.gentoo.org/637252
    Bug: https://bugs.gentoo.org/803308
    Signed-off-by: Sam James <sam@gentoo.org>

 net-misc/curl/Manifest           |   1 +
 net-misc/curl/curl-7.78.0.ebuild | 289 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 290 insertions(+)