Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bigint do not work #539

Closed
rtzui opened this issue Mar 7, 2012 · 25 comments
Closed

bigint do not work #539

rtzui opened this issue Mar 7, 2012 · 25 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior priority This should be addressed urgently

Comments

@rtzui
Copy link

rtzui commented Mar 7, 2012

how to reproduce:

$ git pull
$ make clean;make
$ make test
JULIA test/default
* default
* core
* numbers
* strings
* corelib
* hashing
* arrayops
* sparse
* lapack
* fft
* arpack
* random
* amos
* functional
* bigint
/home/user/julia/lib/libgmp_wrapper.so: undefined symbol: __gmpz_get_si
could not load module libgmp_wrapper
in dlopen at /home/user/julia/jl/base.jl:97
in include at src/boot.jl:192
in load at /home/user/julia/jl/util.jl:174
in include at src/boot.jl:192
in load at /home/user/julia/jl/util.jl:174
in runtests at ./runtests.jl:3
in include at src/boot.jl:192
in load at /home/user/julia/jl/util.jl:174
in load at /home/user/julia/jl/util.jl:186
in runtests at ./runtests.jl:3
in include at src/boot.jl:192
in process_options at /home/user/julia/jl/client.jl:167
in _start at /home/user/julia/jl/client.jl:205
at ../jl/bigint.jl:1
in include at src/boot.jl:192
in load at /home/user/julia/jl/util.jl:174
in include at src/boot.jl:192
in load at /home/user/julia/jl/util.jl:174
in runtests at ./runtests.jl:3
in include at src/boot.jl:192
in load at /home/user/julia/jl/util.jl:174
in load at /home/user/julia/jl/util.jl:186
in runtests at ./runtests.jl:3
in include at src/boot.jl:192
in process_options at /home/user/julia/jl/client.jl:167
in _start at /home/user/julia/jl/client.jl:205
at bigint.jl:2
in include at src/boot.jl:192
in load at /home/user/julia/jl/util.jl:174
in runtests at ./runtests.jl:3
in include at src/boot.jl:192
in load at /home/user/julia/jl/util.jl:174
in load at /home/user/julia/jl/util.jl:186
in runtests at ./runtests.jl:3
in include at src/boot.jl:192
in process_options at /home/user/julia/jl/client.jl:167
in _start at /home/user/julia/jl/client.jl:205
at default.jl:14
in load at /home/user/julia/jl/util.jl:197
in runtests at ./runtests.jl:3
in include at src/boot.jl:192
in process_options at /home/user/julia/jl/client.jl:167
in _start at /home/user/julia/jl/client.jl:205
at ./runtests.jl:48
in include at src/boot.jl:192
in process_options at /home/user/julia/jl/client.jl:167
in _start at /home/user/julia/jl/client.jl:205
make[1]: *** [default] Error 1
make: *** [test] Error 2
$ nm /home/user/julia/lib/libgmp_wrapper.so|grep gmpz
U __gmpz_add
U __gmpz_clear
U __gmpz_cmp
U __gmpz_fdiv_q
U __gmpz_fdiv_r
U __gmpz_get_si
U __gmpz_init
U __gmpz_mul
U __gmpz_pow_ui
U __gmpz_set
U __gmpz_set_si
U __gmpz_set_str
U __gmpz_set_ui
U __gmpz_sqrt
U __gmpz_sub
$ uname -a
Linux tux 3.0.0-16-generic #28-Ubuntu SMP Fri Jan 27 17:44:39 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

@nolta
Copy link
Member

nolta commented Mar 7, 2012

What happens if you try:

$ cd julia/external
$ make distclean-gmp
$ make clean-gmp-wrapper
$ make

and then run the tests?

@rtzui
Copy link
Author

rtzui commented Mar 7, 2012

Nothing changes. Here is to output of nm julia/lib/libgmp_wrapper.so: http://paste.ubuntu.com/873567/

@nolta
Copy link
Member

nolta commented Mar 7, 2012

And what's the output of ls external/root/lib/*gmp*?

@rtzui
Copy link
Author

rtzui commented Mar 7, 2012

$ ls external/root/lib/gmp
external/root/lib/libgmp.a external/root/lib/libgmp.so.10
external/root/lib/libgmp.la external/root/lib/libgmp.so.10.0.4
external/root/lib/libgmp.so external/root/lib/libgmp_wrapper.so
$ strace make test
http://paste.ubuntu.com/873586/

@nolta
Copy link
Member

nolta commented Mar 7, 2012

Ok, how about the output of the following:

$ readelf -d lib/libgmp_wrapper.so
$ ldd lib/libgmp_wrapper.so
$ julia --version

Sorry, just kind of spinning my wheels here since i can't reproduce your problem.

@rtzui
Copy link
Author

rtzui commented Mar 7, 2012

$ readelf -d lib/libgmp_wrapper.so

Dynamic section at offset 0x2e40 contains 21 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000f (RPATH) Library rpath: [/home/user/julia/external/root/lib]
0x000000000000000c (INIT) 0x13c8
0x000000000000000d (FINI) 0x1a98
0x000000006ffffef5 (GNU_HASH) 0x1f0
0x0000000000000005 (STRTAB) 0xac0
0x0000000000000006 (SYMTAB) 0x358
0x000000000000000a (STRSZ) 1046 (bytes)
0x000000000000000b (SYMENT) 24 (bytes)
0x0000000000000003 (PLTGOT) 0x202fe8
0x0000000000000002 (PLTRELSZ) 960 (bytes)
0x0000000000000014 (PLTREL) RELA
0x0000000000000017 (JMPREL) 0x1008
0x0000000000000007 (RELA) 0xfa8
0x0000000000000008 (RELASZ) 96 (bytes)
0x0000000000000009 (RELAENT) 24 (bytes)
0x000000006ffffffe (VERNEED) 0xf78
0x000000006fffffff (VERNEEDNUM) 1
0x000000006ffffff0 (VERSYM) 0xed6
0x000000006ffffff9 (RELACOUNT) 1
0x0000000000000000 (NULL) 0x0
$ ldd lib/libgmp_wrapper.so
linux-vdso.so.1 => (0x00007fff11bff000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f865c225000)
/lib64/ld-linux-x86-64.so.2 (0x00007f865c7ee000)

$ ./julia --version
julia version 0.0.0-prerelease
Commit 2126420 (2012-03-07 13:58:44)

I guess it's quite up to date. It's a 64 bit system.

I don't think this helps, but here it is: $ md5sum lib/libgmp_wrapper.so
0b633a196ab658cea31beffd7502c0d4

@nolta
Copy link
Member

nolta commented Mar 7, 2012

Thanks, now we're getting somewhere. I don't know why, but the wrapper isn't being linked against libgmp. Perhaps the -lgmp flag has gone missing? Did you edit external/Makefile? What's the output of:

$ grep GMP_LIB external/Makefile

@nolta
Copy link
Member

nolta commented Mar 7, 2012

Also, could you git pull and see if that fixes it?

@rtzui
Copy link
Author

rtzui commented Mar 7, 2012

That sounds very strange. No, i haven't changed anything in the makefile.

GMP_LIB = -L$(EXTROOTLIB)/ -lgmp
$(CC) -O2 -shared -fPIC $(GMP_INC) $(GMP_LIB) gmp_wrapper.c -o $(EXTROOTLIB)/libgmp_wrapper.$(SHLIB_EXT) -Wl,-rpath,$(EXTROOTLIB)

building it again looks fine for me: http://paste.ubuntu.com/873664/

But the tests still fail.

@nolta
Copy link
Member

nolta commented Mar 7, 2012

Strange indeed. I don't know what to say at this point, except that -Wl,-rpath,$(EXTROOTLIB) wasn't part of the 2126420 commit, so something is out-of-sync somewhere.

@rtzui
Copy link
Author

rtzui commented Mar 7, 2012

I'll clone it again. But building that will take 2 hours. I'll report tomorrow.

@ghost ghost assigned nolta Mar 8, 2012
@ViralBShah
Copy link
Member

We should also include a USE_SYSTEM_GMP option, if GMP is available on the system.

@ViralBShah
Copy link
Member

On 32-bit linux (Ubuntu 11.10), tests are failing:

$ make test
    JULIA test/default
     * default
     * core
     * numbers
     * strings
     * corelib
     * hashing
     * arrayops
     * sparse
     * lapack
     * fft
     * arpack
     * random
     * amos
     * functional
     * bigint
/home/viral/julia/lib/libgmp_wrapper.so: undefined symbol: __gmpz_get_si
could not load module libgmp_wrapper
 in dlopen at /home/viral/julia/jl/base.jl:97
 in include at src/boot.jl:192
 in load at /home/viral/julia/jl/util.jl:174
 in include at src/boot.jl:192
 in load at /home/viral/julia/jl/util.jl:174
 in runtests at ./runtests.jl:3
 in include at src/boot.jl:192
 in load at /home/viral/julia/jl/util.jl:174
 in load at /home/viral/julia/jl/util.jl:186
 in runtests at ./runtests.jl:3
 in include at src/boot.jl:192
 in process_options at /home/viral/julia/jl/client.jl:166
 in _start at /home/viral/julia/jl/client.jl:204
at ../jl/bigint.jl:1
 in include at src/boot.jl:192
 in load at /home/viral/julia/jl/util.jl:174
 in include at src/boot.jl:192
 in load at /home/viral/julia/jl/util.jl:174
 in runtests at ./runtests.jl:3
 in include at src/boot.jl:192
 in load at /home/viral/julia/jl/util.jl:174
 in load at /home/viral/julia/jl/util.jl:186
 in runtests at ./runtests.jl:3
 in include at src/boot.jl:192
 in process_options at /home/viral/julia/jl/client.jl:166
 in _start at /home/viral/julia/jl/client.jl:204
at bigint.jl:2
 in include at src/boot.jl:192
 in load at /home/viral/julia/jl/util.jl:174
 in runtests at ./runtests.jl:3
 in include at src/boot.jl:192
 in load at /home/viral/julia/jl/util.jl:174
 in load at /home/viral/julia/jl/util.jl:186
 in runtests at ./runtests.jl:3
 in include at src/boot.jl:192
 in process_options at /home/viral/julia/jl/client.jl:166
 in _start at /home/viral/julia/jl/client.jl:204
at default.jl:14
 in load at /home/viral/julia/jl/util.jl:197
 in runtests at ./runtests.jl:3
 in include at src/boot.jl:192
 in process_options at /home/viral/julia/jl/client.jl:166
 in _start at /home/viral/julia/jl/client.jl:204
at ./runtests.jl:48
 in include at src/boot.jl:192
 in process_options at /home/viral/julia/jl/client.jl:166
 in _start at /home/viral/julia/jl/client.jl:204

@nolta
Copy link
Member

nolta commented Mar 8, 2012

Probably because mpz_get_si returns long?

@ViralBShah
Copy link
Member

Why would that lead to the undefined symbol error? This error is due to julia being unable to load gmp_wrapper, presumably because it cannot find libmp and resolve the symbols. Would it be related to your rpath fix, which I thought would have solved this?

I think we need the julia binary to be compiled with the correct rpath and fix this once and for all (#353).

-viral

On 08-Mar-2012, at 9:59 AM, Mike Nolta wrote:

Probably because mpz_get_si returns long?


Reply to this email directly or view it on GitHub:
#539 (comment)

@nolta
Copy link
Member

nolta commented Mar 8, 2012

Why would that lead to the undefined symbol error?

Sorry, i'm exhausted.

Would it be related to your rpath fix, which I thought would have solved this?

That's what i'm worried about. Do the tests succeed if you take it out?

@aviks
Copy link
Member

aviks commented Mar 8, 2012

I tried this with a fresh gmp build on a 32 bit ubuntu 11.4, and everything seems to load correctly. (One of the asserts failed on 32 bits, which I'll fix, but the load was fine)

2.6.38-13-generic-pae #54-Ubuntu SMP Tue Jan 3 15:11:05 UTC 2012 i686 i686 i386 GNU/Linux

So one possible problem is path's etc, which should be easy to check via ldd. eg, I have:

aviks@asterix:~/dev/julia$ ldd external/root/lib/libgmp_wrapper.so 
    linux-gate.so.1 =>  (0xb7783000)
    libgmp.so.10 => /home/aviks/dev/julia/external/root/lib/libgmp.so.10 (0xb7717000)
    libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb75ac000)
    /lib/ld-linux.so.2 (0xb7784000)
aviks@asterix:~/dev/julia$ 2.6.38-13-generic-pae #54-Ubuntu SMP Tue Jan 3 15:11:05 UTC 2012 i686 i686 i386 GNU/Linux

However, gmp has some smarts in how it exposes function names. While clients call functions like mpz_get_si , libgmp exported functions are of the type __gmpz_get_si which are mapped via the .h files. So one possible explanation would be that when the wrapper is compiled, its using a different include from the one used when libgmp was compiled (maybe due to system vs downloaded gmp's?)

So it would make sense to check the exported symbols from any libgmp on the system against what the wrapper is trying to load.

@rtzui
Copy link
Author

rtzui commented Mar 8, 2012

Started with a fresh clone, build it and now i got:

 $ ldd external/root/lib/libgmp_wrapper.so 
    linux-vdso.so.1 =>  (0x00007fff02881000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc355aca000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fc356093000)
 $ uname -a
 Linux kyon 3.0.0-16-generic #28-Ubuntu SMP Fri Jan 27 17:44:39 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

@nolta
Copy link
Member

nolta commented Mar 8, 2012

Thanks for double checking. I may try replicating your system -- which version of Ubuntu are you running? And is the gmp package installed?

Started with a fresh clone, build it and now i got:

$ ldd external/root/lib/libgmp_wrapper.so 
   linux-vdso.so.1 =>  (0x00007fff02881000)
   libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc355aca000)
   /lib64/ld-linux-x86-64.so.2 (0x00007fc356093000)
$ uname -a
Linux kyon 3.0.0-16-generic #28-Ubuntu SMP Fri Jan 27 17:44:39 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

Reply to this email directly or view it on GitHub:
#539 (comment)

@ViralBShah
Copy link
Member

BTW, this is how libsuitesparse_wrapper also looks, but it loads just fine.

-viral

On 08-Mar-2012, at 10:01 PM, Mike Nolta wrote:

Thanks for double checking. I may try replicating your system -- which version of Ubuntu are you running? And is the gmp package installed?

Started with a fresh clone, build it and now i got:

$ ldd external/root/lib/libgmp_wrapper.so 
  linux-vdso.so.1 =>  (0x00007fff02881000)
  libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc355aca000)
  /lib64/ld-linux-x86-64.so.2 (0x00007fc356093000)
$ uname -a
Linux kyon 3.0.0-16-generic #28-Ubuntu SMP Fri Jan 27 17:44:39 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

Reply to this email directly or view it on GitHub:
#539 (comment)


Reply to this email directly or view it on GitHub:
#539 (comment)

@rtzui
Copy link
Author

rtzui commented Mar 8, 2012

Ubuntu 11.10, the downloaded libgmp.

@ViralBShah
Copy link
Member

Removing -rpath does not change anything for me. I am on ubuntu 11.10 as well.

-viral

On 08-Mar-2012, at 10:53 PM, rtzui wrote:

Ubuntu 11.10, the downloaded libgmp.


Reply to this email directly or view it on GitHub:
#539 (comment)

@nolta
Copy link
Member

nolta commented Mar 8, 2012

Ok, success (of a sort): i can reproduce this bug on Ubuntu 11.10.

@nolta
Copy link
Member

nolta commented Mar 8, 2012

I've pushed a fix for both @rtzui and @aviks bugs.

@rtzui
Copy link
Author

rtzui commented Mar 8, 2012

works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior priority This should be addressed urgently
Projects
None yet
Development

No branches or pull requests

4 participants