From ross at biostat.ucsf.edu  Thu Mar 13 18:46:31 2014
From: ross at biostat.ucsf.edu (Ross Boylan)
Date: Thu, 13 Mar 2014 10:46:31 -0700
Subject: [Rd] 2 versions of same library loaded
In-Reply-To: <E66794E69CFDE04D9A70842786030B933FA936DE@PA-MBX01.na.tibco.com>
References: <1394660055.25697.92.camel@localhost>
	<E236A681-5D73-478E-8FB2-3B04837B00DA@r-project.org>
	<1394686856.15874.16.camel@localhost>
	<E66794E69CFDE04D9A70842786030B933FA936DE@PA-MBX01.na.tibco.com>
Message-ID: <1394732791.15874.53.camel@localhost>

On Thu, 2014-03-13 at 15:21 +0000, William Dunlap wrote:
> Have you tried using the environment variable LD_DEBUG to
> see what the dynamic linker is doing?  E.g.,
> 
>   env LD_DEBUG=files R
> or
That was very helpful.  I'm still having trouble determining exactly
which file is getting loaded, because the trace sometimes does not
include the complete path.  However, judging by calls to init I can see

1. My premise that R had no references to mpi was incorrect.  The logs
show      
24312:     file=libmpi.so.1 [0];  needed by /home/ross/Rlib-3.0.1/Rmpi/libs/Rmpi.so [0]
24312:     find library=libmpi.so.1 [0]; searching
24312:      search path=/usr/lib64/R/lib:/home/ross/install/lib            (LD_LIBRARY_PATH)
24312:       trying file=/usr/lib64/R/lib/libmpi.so.1
24312:       trying file=/home/ross/install/lib/libmpi.so.1

I used 
   env LD_DEBUG='libs files versions' R 
to try to get more clues about what was going on.

2.  There are calls to init for 
calling init: /home/ross/install/lib/libmpi.so.1
calling init: /usr/lib/libmpi.so.0
in that order.

mpi.so.0 is there because
     24312:     file=libmpi.so.0 [0];  needed by /home/ross/Rlib-3.0.1/Rmpi/libs/Rmpi.so [0]
     24312:     find library=libmpi.so.0 [0]; searching
     24312:      search path=/usr/lib64/R/lib:/home/ross/install/lib            (LD_LIBRARY_PATH)
     24312:       trying file=/usr/lib64/R/lib/libmpi.so.0
     24312:       trying file=/home/ross/install/lib/libmpi.so.0
     24312:      search cache=/etc/ld.so.cache
     24312:       trying file=/usr/lib/libmpi.so.0

It seems very odd that the same Rmpi.so is requiring both the old and new libmpi.so (compare to the first 
trace in in point 1).  There is this code in Rmpi.c:
    if (!dlopen("libmpi.so.0", RTLD_GLOBAL | RTLD_LAZY)
        && !dlopen("libmpi.so", RTLD_GLOBAL | RTLD_LAZY)){


So I'm still not sure what it's using, or if there is some mishmash of the 2.

It might be relevant that 
     24312:     calling init: /home/ross/Rlib-3.0.1/Rmpi/libs/Rmpi.so
     24312:
     24312:     opening file=/home/ross/Rlib-3.0.1/Rmpi/libs/Rmpi.so [0]; direct_opencount=1
     24312:
     24312:     /home/ross/Rlib-3.0.1/Rmpi/libs/Rmpi.so: error: symbol lookup error: undefined symbol: R_init_Rmpi (fatal)
     24312:     /home/ross/Rlib-3.0.1/Rmpi/libs/Rmpi.so: error: symbol lookup error: undefined symbol: R_init_Rmpi (fatal)

ldd on Rmpi.so has no mention of mpi.so.0:
$ ldd /home/ross/Rlib-3.0.1/Rmpi/libs/Rmpi.so
        linux-vdso.so.1 =>  (0x00007fff69135000)
        libmpi.so.1 => /home/ross/install/lib/libmpi.so.1 (0x00007f899b579000)
        libR.so => /usr/lib/libR.so (0x00007f899af8c000)
        libc.so.6 => /lib/libc.so.6 (0x00007f899ac29000)
        libibverbs.so.1 => /usr/lib/libibverbs.so.1 (0x00007f899aa1d000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00007f899a801000)
        libopen-rte.so.7 => /home/ross/install/lib/libopen-rte.so.7 (0x00007f899a518000)
        libtorque.so.2 => /usr/lib/libtorque.so.2 (0x00007f899a208000)
        libopen-pal.so.6 => /home/ross/install/lib/libopen-pal.so.6 (0x00007f8999f34000)
        libdl.so.2 => /lib/libdl.so.2 (0x00007f8999d2f000)
        libnuma.so.1 => /usr/lib/libnuma.so.1 (0x00007f8999b27000)
        libpciaccess.so.0 => /usr/lib/libpciaccess.so.0 (0x00007f899991f000)
        librt.so.1 => /lib/librt.so.1 (0x00007f8999716000)
        libnsl.so.1 => /lib/libnsl.so.1 (0x00007f89994fe000)
        libutil.so.1 => /lib/libutil.so.1 (0x00007f89992fb000)
        libm.so.6 => /lib/libm.so.6 (0x00007f8999078000)
        libblas.so.3gf => /usr/lib/libblas.so.3gf (0x00007f8998b58000)
        libgfortran.so.3 => /usr/lib/libgfortran.so.3 (0x00007f899886c000)
        libreadline.so.6 => /lib/libreadline.so.6 (0x00007f8998627000)
        libgomp.so.1 => /usr/lib/libgomp.so.1 (0x00007f899841a000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f899bc6e000)
        libz.so.1 => /usr/lib/libz.so.1 (0x00007f8998202000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007f8997fec000)
        libncurses.so.5 => /lib/libncurses.so.5 (0x00007f8997da6000)



[Rd] 2 versions of same library loaded
Ross Boylan