Bug 835965 - Unable to link libcrypt.a due to unresolved NSSLOW* references
Summary: Unable to link libcrypt.a due to unresolved NSSLOW* references
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc
Version: 16
Hardware: i686
OS: Linux
unspecified
urgent
Target Milestone: ---
Assignee: Jeff Law
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-06-27 17:05 UTC by Eric Promislow
Modified: 2016-11-24 12:20 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-06-29 18:29:58 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Eric Promislow 2012-06-27 17:05:24 UTC
Description of problem:

I can't build the mysql2 gem for Ruby 1.9.2 because of a failure
during the 'gem install' configure step. It wrongly assumes a
feature of Ruby is missing because it fails to build conftest (source
below), but in fact the build failure happens because I'm missing
a dependency (details below).

Version-Release number of selected component (if applicable):

Fedora Core 16

Ruby 1.9.2-p320 (built from source, required to repro)
mysql2-0.3.11.gem (built from source, not required to repro)


How reproducible:

Full details at http://stackoverflow.com/questions/11218734/where-can-i-get-the-nsslowhash-lib-from-for-fedora-16-source-preferably, but here they are repeated:

gremlin:mysql2 $ cat conftest.c
    #include "ruby.h"

    /*top*/
    int main() {return 0;}
    int t() {
      void ((*volatile p)());
      p = (void ((*)()))rb_thread_blocking_region;
      return 0;
    }

gremlin:mysql2 $ gcc -o conftest -I/usr/local/include/ruby-1.9.1/i686-linux \
    -I/usr/local/include/ruby-1.9.1/ruby/backward 
    -I/usr/local/include/ruby-1.9.1 -I. 
    -I/usr/local/include/ruby-1.9.1/  
    -D_FILE_OFFSET_BITS=64   -O3 -ggdb -Wextra -Wno-unused-parameter 
    -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers
    -Wno-long-long conftest.c  -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L.  
    -rdynamic -Wl,-export-dynamic     -Wl,-R -Wl,/usr/local/lib -L/usr/local/lib 
    -lruby-static  -lpthread -lrt -ldl -lnss3 -lcrypt -lm   -lc

    /usr/lib/gcc/i686-redhat-linux/4.6.3/../../../libcrypt.a(md5-crypt.o): 
    In function `__md5_crypt_r':
            (.text+0x96): undefined reference to `NSSLOW_Init'

    /usr/lib/gcc/i686-redhat-linux/4.6.3/../../../libcrypt.a(md5-crypt.o): 
    In function `__md5_crypt_r':
            (.text+0xb1): undefined reference to `NSSLOWHASH_NewContext'

[... and many similar messages elided, all dealing with missing references
in libcrypt.a to names that start with "NSSLOWHASH" ...]


Steps to Reproduce:

Download ruby 1.9.2-p320 from http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p320.tar.gz, build, and install (I went with the default /usr/local)

Create the above conftest.c file

Run this command:

gcc -o conftest -I/usr/local/include/ruby-1.9.1/i686-linux -I/usr/local/include/ruby-1.9.1/ruby/backward -I/usr/local/include/ruby-1.9.1 -I. -I/usr/local/include/ruby-1.9.1/  -D_FILE_OFFSET_BITS=64   -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long conftest.c  -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L.  -rdynamic -Wl,-export-dynamic     -Wl,-R -Wl,/usr/local/lib -L/usr/local/lib -lruby-static  -lpthread -lrt -ldl -lcrypt -lm   -lc

  
Actual results:

Linker errors as listed above

Expected results:

A working conftest executable that does nothing and exits with status 0

Additional info:

I see that the NSSLOW* names are defined in the security/nss/lib/freebl part of the core Mozilla-central code, but I don't know how to go about building a library containing them.  Nor do I know which common library contains these names. I tried yum-installing nss and nss-devel, but it's not obvious which library to use.  It only installed *.so files, not .a's.

Comment 1 Eric Promislow 2012-06-28 17:02:53 UTC
This is a blocker for me. To the point where I'll have to pave the machine and install Ubuntu.

I don't need a fix -- I just need to know what to link to.  If I add "-lnss3"
to the above command it makes no difference. But there's no /usr/lib/libnss3.a,
just /usr/lib/libnss3.so, and I can't tell if that's where these functions are defined. nm doesn't give symbols for a shared library -- is there another utility that does, or an option for nm?

So, again, not expecting a bug fix, just a pointer.

Comment 2 Tomáš Bžatek 2012-06-29 12:29:58 UTC
libcryptui != libcrypt

Comment 3 Eric Promislow 2012-06-29 16:52:59 UTC
I know that, but I didn't know which component to pick, so I went by Levenstein distance.

I'm just trying to build a gem so I can write a web app.  MySQL, Rails 3.0.8, Ruby 1.9.2.  Nothing cutting edge. And I've stumbled on this problem in core Fedora.

I see it's a glibc bug.  Guess my next step is to try to rebuild libcrypt.a,
assuming there's a #ifdef that I can turn off so it doesn't assume the NSSSLOW* functions are available.

Comment 4 Jeff Law 2012-06-29 18:29:58 UTC
Strangely enough it works fine for me.

I installed a fresh F16 i686 inside a VM.  Built & installed ruby-1.9.2 and ran the list without receiving any errors.

THe NSSLOW symbols are provided by /usr/lib/libfreebl3.so:

nm --print-file-name --dynamic /usr/lib/libfreebl3.so  | grep NSSLOW
/usr/lib/libfreebl3.so:00034130 T NSSLOWHASH_Begin
/usr/lib/libfreebl3.so:000341b0 T NSSLOWHASH_Destroy
/usr/lib/libfreebl3.so:00034180 T NSSLOWHASH_End
/usr/lib/libfreebl3.so:00034200 T NSSLOWHASH_Length
/usr/lib/libfreebl3.so:00034080 T NSSLOWHASH_NewContext
/usr/lib/libfreebl3.so:00034150 T NSSLOWHASH_Update
/usr/lib/libfreebl3.so:00033f60 T NSSLOW_Init
/usr/lib/libfreebl3.so:00034040 T NSSLOW_Shutdown

[root@localhost tmp]# rpm -q --whatprovides /usr/lib/libfreebl3.so
nss-softokn-freebl-3.12.10-4.fc16.i686

Comment 5 Jeff Law 2012-06-29 18:31:11 UTC
Note that libcrypt references freebl3.so:

[root@localhost tmp]# readelf --dynamic /usr/lib/libcrypt.so 

Dynamic section at offset 0x7ee8 contains 26 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x00000001 (NEEDED)                     Shared library: [libfreebl3.so]
 0x0000000e (SONAME)                     Library soname: [libcrypt.so.1]

Comment 6 Eric Promislow 2012-06-30 00:43:28 UTC
The gcc step works when I add "-lfreebl3".

Thanks for the reply, Jeff.  I'm not sure why I don't have the .so files you
reference, but I got the build to work.

gremlin:ericp lib $ cat /etc/fedora-release 
Fedora release 16 (Verne)
gremlin:ericp lib $ pwd
/usr/lib
gremlin:ericp lib $ ls -l libcrypt.*
-rw-r--r-- 1 root root 43834 May 14 15:59 libcrypt.a
gremlin:ericp lib $ ls -l libfreebl
libfreebl3.chk  libfreebl3.so   libfreebl.a     
gremlin:ericp lib $ ls -l libfreebl*
lrwxrwxrwx 1 root root    19 Jun 26 22:08 libfreebl3.chk -> /lib/libfreebl3.chk
lrwxrwxrwx 1 root root    18 Jun 26 22:08 libfreebl3.so -> /lib/libfreebl3.so
-rw-r--r-- 1 root root 44740 Apr  7 14:55 libfreebl.a
gremlin:ericp lib $ ls -l /lib/libfreebl*
-rw-r--r-- 1 root root    478 Apr  7 14:55 /lib/libfreebl3.chk
-rwxr-xr-x 1 root root 306492 Apr  7 14:55 /lib/libfreebl3.so

If any Rubyists arrive here looking for a fix, the solution is to modify
the CONFIG["LIBS"] line in .../i686-linux/rbconfig.rb: add "-lfreebl3"
after "-lcrypt", and gem will work.


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