LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   problem with ldconfig (https://www.linuxquestions.org/questions/slackware-14/problem-with-ldconfig-4175668361/)

BCarey 01-24-2020 11:44 AM

problem with ldconfig
 
Hi,

So a while back I was having problems with installpkg hanging. I finally got back to this and isolated the problem to the ldconfig part of installpkg. Lo and behold running ldconfig hung. So I tried the various directories in ldconfig.conf with -n and all of them ran fine except one, /usr/lib64, which hangs. Any ideas where I can go from here?

Thanks

Didier Spaier 01-24-2020 12:35 PM

Is ldconfig.conf a file you wrote or do you actually mean the file /etc/ld.so.conf? Anyway I don't observe this behavior here, ldconfig runs usually instantly.

BCarey 01-24-2020 12:38 PM

Sorry, I meant ld.so.conf.

volkerdi 01-24-2020 02:55 PM

This is just a shot in the dark, but maybe your ld.so.cache has become corrupted?

You could try this:
Code:

rm /etc/ld.so.cache
ldconfig


volkerdi 01-24-2020 03:03 PM

Another thought is that perhaps a library in /usr/lib64 has become corrupted. While this one-liner can't guarantee there are no corrupted files, it would at least point out any that are corrupted enough that "file" no longer sees them as ELF objects:

Code:

file /usr/lib64/*.so.* | grep -v ELF | grep -v symbolic | grep -v Python

BCarey 01-25-2020 10:59 AM

Quote:

Originally Posted by volkerdi (Post 6082606)
This is just a shot in the dark, but maybe your ld.so.cache has become corrupted?

You could try this:
Code:

rm /etc/ld.so.cache
ldconfig


Thank you so much for responding to this. Unfortunately I already tried this and it did not help.

BCarey 01-25-2020 11:03 AM

Quote:

Originally Posted by volkerdi (Post 6082610)
Another thought is that perhaps a library in /usr/lib64 has become corrupted. While this one-liner can't guarantee there are no corrupted files, it would at least point out any that are corrupted enough that "file" no longer sees them as ELF objects:

Code:

file /usr/lib64/*.so.* | grep -v ELF | grep -v symbolic | grep -v Python

Again thanks for your help (I'm honored really). I ran this and there was no output. I've been manually testing groups of these libraries but haven't come up yet with any that hang, but I'm not done.

crts 01-25-2020 04:13 PM

Here are a few more ideas.
First, please ensure that the harddisk is not failing and the delay is caused by some faulty I/O operation. You probably would have noticed during normal operation but let us get this out of the way, anyway.
Second, are you by any chance in a VM? I do recall some time ago to have experienced a similar issue when running slackware in virtualbox.

With the above out of the way I came up with three scripts that may help you diagnose the problem. For a better overview I will post them in three separate posts instead of making one huge bulky post.

All scripts must NOT be run as root. All scripts expect the library directory to check as parameter $1. All scripts will produce a logfile which will store the library name and the elapsed time (milliseconds) it took to process aforementioned library.

You can use the elapsed time to determine which libraries take the longest to process and possibly cause 'ldconfig' to hang.

crts 01-25-2020 04:13 PM

Script number #1
 
Script number #1 will run 'ldconfig' on every library in the folder specified in parameter $1.
I *think* when the -l option is passed to 'ldfonfig' then it will not update the cache, however, it will try to update the links. In addition to running the script as normal user the '-NX' option will ensure that neither happens, so nothing should be updated and/or break.
The resuls will be stored in a file called 'ldconf.log' in the current folder (see below for sample output).

Code:

#!/bin/bash

if (( $(id -u) == 0 || $(id -g) == 0 ));then
        echo "Please do NOT run this script as root or any priviledged user"
        exit 1
fi

if [[ ! -d "$1" ]];then
        echo "Please specify a directory to check"
        exit 2
fi

declare -i millis

update_millis() {
        local -i nanos=$(date '+%s%N')
        # nanos to millis
        millis=${nanos:0:${#nanos}-6}
}

delta_stamp() {
        local -r last=$millis
        update_millis
        echo "=== $1 Elapsed: $(( millis - last )) ms ==="
}

exec &>ldconf.log

update_millis
while read l;do
        /sbin/ldconfig -vNXl "$l"
        delta_stamp "$l"
done < <(find "$1" -type f -name '*.so.*')

Sample output:
Code:

        libsmartcols.so.1 -> libsmartcols.so.1.1.0
=== /lib64/libsmartcols.so.1.1.0 Elapsed: 21 ms ===
        libpcreposix.so.0 -> libpcreposix.so.0.0.4
=== /lib64/libpcreposix.so.0.0.4 Elapsed: 13 ms ===
        libulockmgr.so.1 -> libulockmgr.so.1.0.1
=== /lib64/libulockmgr.so.1.0.1 Elapsed: 13 ms ===
...

It simply lists the symbolic link it would have created.

crts 01-25-2020 04:14 PM

Script number #2
 
Script number #2 will use the dynamic linker to verify the library and try to list its dependencies. If the library is corrupted then this might diagnose it. The results will be stored in a logfile called 'ld.so.log' in the current directory.

Code:

#!/bin/bash

if (( $(id -u) == 0 || $(id -g) == 0 ));then
        echo "Please do NOT run this script as root or any priviledged user"
        exit 1
fi

if [[ ! -d "$1" ]];then
        echo "Please specify a directory to check"
        exit 2
fi

declare -i millis

update_millis() {
        local -i nanos=$(date '+%s%N')
        # nanos to millis
        millis=${nanos:0:${#nanos}-6}
}

delta_stamp() {
        local -r last=$millis
        update_millis
        echo "=== $1 Elapsed: $(( millis - last )) ms ==="
}

exec &>ld.so.log

LDSO="/lib64/ld-linux-x86-64.so.2"
if [[ ! -x $LDSO ]];then
        echo "Sorry, $LDSO was not found." >&2
        exit 1
fi

update_millis
while read l;do
        $LDSO --verify "$l"
        echo -n "$l            "
        [[ $? = [02] ]] && echo "OK" || echo "UNVERIFIED"
        $LDSO --list "$l"
        [[ $? = [0] ]] || echo "FAILED to list shared libs."
        delta_stamp "$l"
done < <(find "$1" -type f -name '*.so.*')

Sample output:

Code:

/lib64/libsmartcols.so.1.1.0            OK
        linux-vdso.so.1 (0x00007ffc25fc3000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fc08abdf000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fc08b1cb000)
=== /lib64/libsmartcols.so.1.1.0 Elapsed: 18 ms ===
/lib64/libpcreposix.so.0.0.4            OK
        linux-vdso.so.1 (0x00007fff1c88d000)
        libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f39e80c8000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f39e7eab000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f39e7ae2000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f39e853d000)
=== /lib64/libpcreposix.so.0.0.4 Elapsed: 9 ms ===
...

The result of the verification check and a list of dependencies for each checked library are logged.

crts 01-25-2020 04:14 PM

Script number #3
 
Script number #3 uses 'ldd' to check the dependencies of each library. The results will be stored in a logfile called 'ldd.log' in the current folder.

IMPORTANT:
Here is a verbatim warning from the manpage of 'ldd':
Quote:

Security
In the usual case, ldd invokes the standard dynamic linker (see ld.so(8)) with the
LD_TRACE_LOADED_OBJECTS environment variable set to 1, which causes the linker to
display the library dependencies. Be aware, however, that in some circumstances,
some versions of ldd may attempt to obtain the dependency information by directly
executing the program. Thus, you should never employ ldd on an untrusted executable,
since this may result in the execution of arbitrary code.
Since we may be dealing with potentially corrupted libraries, there is a small chance the execution of such library may damage the system. Even though that chance may be practically negligible and a corrupted library will most probably just segfault, it is still something to be aware of before proceeding.

Code:

#!/bin/bash

if (( $(id -u) == 0 || $(id -g) == 0 ));then
        echo "Please do NOT run this script as root or any priviledged user"
        exit 1
fi

if [[ ! -d "$1" ]];then
        echo "Please specify a directory to check"
        exit 2
fi

declare -i millis

update_millis() {
        local -i nanos=$(date '+%s%N')
        # nanos to millis
        millis=${nanos:0:${#nanos}-6}
}

delta_stamp() {
        local -r last=$millis
        update_millis
        echo "=== $1 Elapsed: $(( millis - last )) ms ==="
}

exec &>ldd.log

update_millis
while read l;do
        ldd "$l"
        [[ $? = [0] ]] || echo "FAILED to list shared libs."
        delta_stamp "$l"
done < <(find "$1" -type f -name '*.so.*')

Sample output:

Code:

        linux-vdso.so.1 (0x00007fff0b3b6000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fe4fd986000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fe4fdf72000)
=== /lib64/libsmartcols.so.1.1.0 Elapsed: 29 ms ===
        linux-vdso.so.1 (0x00007ffef144a000)
        libpcre.so.1 => /lib64/libpcre.so.1 (0x00007ff481aa5000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ff481888000)
        libc.so.6 => /lib64/libc.so.6 (0x00007ff4814bf000)
        /lib64/ld-linux-x86-64.so.2 (0x00007ff481f1a000)
=== /lib64/libpcreposix.so.0.0.4 Elapsed: 23 ms ===

Just the dependencies of each library.


All times are GMT -5. The time now is 10:33 AM.