Bug 2181668 - gdb: symbol lookup error: /lib64/libldap.so.2: undefined symbol: EVP_md2, version OPENSSL_3.0.0
Summary: gdb: symbol lookup error: /lib64/libldap.so.2: undefined symbol: EVP_md2, ver...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: openldap
Version: 37
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Simon Pichugin
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-03-24 22:24 UTC by Jun Aruga
Modified: 2023-03-28 15:10 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-03-28 15:10:26 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1909037 0 medium CLOSED got undefined symbol: EVP_md2, version OPENSSL_1_1_0 after upgrading from openldap-2.4.46-11 to openldap-2.4.46-15 2024-03-25 17:39:48 UTC

Description Jun Aruga 2023-03-24 22:24:41 UTC
Description of problem:

I installed the latest openssl 3.0 version 3.0.8 from the source to use a configured openssl on Fedora 37 x86_64. I downloaded the openssl 3.0.8 source from <https://www.openssl.org/source/>. In this example, the configure options are simple, because the error happens with the openssl too. My real use case is to debug Ruby's OpenSSL binding with the specific openssl.

```
$ LD_LIBRARY_PATH=/home/jaruga/.local/openssl-3.0.8/lib/ \
  gdb --args /usr/bin/ruby-mri -v
gdb: symbol lookup error: /lib64/libldap.so.2: undefined symbol: EVP_md2, version OPENSSL_3.0.0
```

```
$ ./Configure --prefix=$HOME/.local/openssl-3.0.8 --libdir=lib shared linux-x86_64
$ make -j4
$ make install
```

Then when running gdb for the the Ruby binary (`ruby-mri`), I got the following error that is about the `libldap.so.2`.

```
$ cat ~/.config/gdb/gdbinit 
set breakpoint pending on
set debuginfod enabled on

$ cat ~/.config/gdb/gdbearlyinit 
set startup-quietly on

$ LD_LIBRARY_PATH=/home/jaruga/.local/openssl-3.0.8/lib/ \
  gdb --args /usr/bin/ruby-mri -v
gdb: symbol lookup error: /lib64/libldap.so.2: undefined symbol: EVP_md2, version OPENSSL_3.0.0
```

This error doesn't happen without `LD_LIBRARY_PATH`.

```
$ gdb --args /usr/bin/ruby-mri -v
Reading symbols from /usr/bin/ruby-mri...
Reading symbols from /home/jaruga/.cache/debuginfod_client/8e0cc1bec324c8a2a63c30e6809173c3dd0963b9/debuginfo...
(gdb) 
```

The `rubyri -v` works.

```
$ /usr/bin/ruby-mri -v
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
```

The command without `gdb` also works.

```
$ LD_LIBRARY_PATH=/home/jaruga/.local/openssl-3.0.8/lib/ \
  /usr/bin/ruby-mri -v
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
```

This issue is very similar with the <https://bugzilla.redhat.com/show_bug.cgi?id=1909037>. When running the testing command to check the issue, I saw 2 `EVP_md2` in the binary.

```
$ ls -l /usr/lib64/libldap*
-rwxr-xr-x. 1 root root  15144 Mar  8 00:53 /usr/lib64/libldap-2.4.so.2*
lrwxrwxrwx. 1 root root     16 Mar  8 00:53 /usr/lib64/libldap-2.4.so.2.0.200 -> libldap-2.4.so.2*
-rwxr-xr-x. 1 root root  15152 Mar  8 00:53 /usr/lib64/libldap_r-2.4.so.2*
lrwxrwxrwx. 1 root root     18 Mar  8 00:53 /usr/lib64/libldap_r-2.4.so.2.0.200 -> libldap_r-2.4.so.2*
lrwxrwxrwx. 1 root root     18 Mar  8 00:52 /usr/lib64/libldap.so.2 -> libldap.so.2.0.200*
-rwxr-xr-x. 1 root root 413632 Mar  8 00:53 /usr/lib64/libldap.so.2.0.200*

$ strings /usr/lib64/libldap* | grep -c EVP_md2
2

$ strings /usr/lib64/libldap* | grep EVP_md2
EVP_md2
EVP_md2
```

Could you tell me why this happened? Is there a workaround to avoid this? Thanks.


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

```
$ rpm -qf /lib64/libldap.so.2
openldap-2.6.4-1.fc37.x86_64

$ rpm -q openssl
openssl-3.0.8-1.fc37.x86_64

$ rpm -q gdb
gdb-12.1-6.fc37.x86_64

$ rpm -qf /usr/bin/ruby-mri
ruby-3.1.2-169.fc37.x86_64

$ file /usr/bin/ruby-mri
/usr/bin/ruby-mri: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=8e0cc1bec324c8a2a63c30e6809173c3dd0963b9, for GNU/Linux 3.2.0, stripped
```


How reproducible:

Steps to Reproduce:
1. Install OpenSSL 3.0.8 from the source. See the above.
2. sudo dnf install ruby gdb
3. Run the command below referring the installed openssl's lib directory. 
  LD_LIBRARY_PATH=/home/jaruga/.local/openssl-3.0.8/lib/ /usr/bin/ruby-mri -v

Actual results:
gdb: symbol lookup error: /lib64/libldap.so.2: undefined symbol: EVP_md2, version OPENSSL_3.0.0

Expected results:
Without the error, the gdb prompt should be shown.
(gdb) 

Additional info:

Comment 1 Jun Aruga 2023-03-27 15:14:15 UTC
Actually this error happens just without specifying the `ruby-mri` command.

```
$ rpm -qf /lib64/libldap.so.2
openldap-2.6.4-1.fc37.x86_64

$ rpm -q gdb
gdb-13.1-1.fc37.x86_64

$ ldd /bin/gdb | grep ldap
	libldap.so.2 => /lib64/libldap.so.2 (0x00007f147899a000)

$ LD_LIBRARY_PATH=/home/jaruga/.local/openssl-3.0.8/lib/ gdb
gdb: symbol lookup error: /lib64/libldap.so.2: undefined symbol: EVP_md2, version OPENSSL_3.0.0

$ echo $?
127
```

Comment 2 Jun Aruga 2023-03-27 15:31:28 UTC
I checked by building the rpms/openldap on the rawhide, it seems that the set of `EVP_md2` strings are also included.

```
<mock-chroot> sh-5.2$ rpm -q openldap
openldap-2.6.4-1.fc39.x86_64

<mock-chroot> sh-5.2$ strings /usr/lib64/libldap* | grep -c EVP_md2
3

<mock-chroot> sh-5.2$ strings /usr/lib64/libldap* | grep EVP_md2
EVP_md2
EVP_md2
EVP_md2
```

Comment 3 Viktor Ashirov 2023-03-28 08:26:47 UTC
> $ ./Configure --prefix=$HOME/.local/openssl-3.0.8 --libdir=lib shared linux-x86_64

Check openssl's spec file: https://src.fedoraproject.org/rpms/openssl/blob/f37/f/openssl.spec#_231
It enables MD2, among other options.

If you enable it too, the symbol will be there:

# ./Configure --prefix=$HOME/.local/openssl-3.0.8.md2 --libdir=lib shared linux-x86_64 enable-md2
# make
# make install
# nm -D /root/.local/openssl-3.0.8.md2/lib/libcrypto.so.3 | grep EVP_md2
0000000000200450 T EVP_md2@@OPENSSL_3.0.0

Comment 4 Jun Aruga 2023-03-28 13:11:41 UTC
> Could you tell me why this happened? Is there a workaround to avoid this? Thanks.

I was told the workaround at the devel@ mailing list below.

https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/5Y2S2QUSC4O27DMCXKFDUJQSOIRBKTU4/

> Yes. gdb expects system openssl (providing this function)
>
> To workaround it, you have to provide the LD_SET_LIBRARY inside gdb, via
> (gdb) set environment LD_LIBRARY_PATH /home/jaruga/.local/openssl-3.0.8/lib/

I hope this issue will be fixed to prevent people's confusion.


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