# ld-elf.so.1: /usr/local/bin/dig: Undefined symbol "pthread_setname_np@FBSD_1.6"



## ADH (May 20, 2021)

Hello all,

```
#dig      shows the message 
ld-elf.so.1: /usr/local/bin/dig: Undefined symbol "pthread_setname_np@FBSD_1.6"

# nslookup
ld-elf.so.1: /usr/local/bin/nslookup: Undefined symbol "pthread_setname_np@FBSD_1.6"
#
```

The OS version is shown as below

```
# uname -a
FreeBSD 12.2-RELEASE-p6 FreeBSD 12.2-RELEASE-p6 GENERIC  i38
# freebsd-version -uk
12.2-RELEASE-p6
12.1-RELEASE
#
```
How to resolve ? Please Help

Thanks


----------



## SirDice (May 20, 2021)

ADH said:


> The OS version is shown as below
> # uname -a
> FreeBSD 12.2-RELEASE-p6 FreeBSD 12.2-RELEASE-p6 GENERIC i38
> # freebsd-version -uk
> ...


You have a botched or incomplete upgrade. Your userland is still 12.1. Finish the upgrade.


----------



## ADH (May 20, 2021)

SirDice said:


> You have a botched or incomplete upgrade. Your userland is still 12.1. Finish the upgrade.


Dear SirDice,

Thanks,

these messages are shown at 12.1 too,

now the userland is 12.2, but it shown same messages

```
#
# freebsd-version -uk
12.2-RELEASE-p6
12.2-RELEASE-p6
# dig
ld-elf.so.1: /usr/local/bin/dig: Undefined symbol "pthread_setname_np@FBSD_1.6"
# nslookup
ld-elf.so.1: /usr/local/bin/nslookup: Undefined symbol "pthread_setname_np@FBSD_1.6"
#
```


----------



## zirias@ (May 20, 2021)

We've seen this problem quite a few times. SirDice is correct, though. This symbol version is definitely there in 12.2, I even tried to reproduce it in a VM, upgrading it to 12.2 with freebsd-update(8), and couldn't. So, your upgrade is somehow incomplete. Make sure you follow the procedure completely.


----------



## SirDice (May 20, 2021)

ADH said:


> now the userland is 12.2


Good, did you reboot? Then update your packages too. I'm guessing they're old too.


----------



## zirias@ (May 20, 2021)

SirDice said:


> Good, did you reboot? Then update your packages too. I'm guessing they're old too.


Rebooting is unlikely to help, updating packages won't help with this for sure (although it will be necessary of course):

The symbol in question is in the threading library, which is part of base:

```
$ objdump -TC /usr/lib/libpthread.so | grep pthread_setname_np
0000000000011950  w   DF .text    0000000000000296  FBSD_1.6    pthread_setname_np
```

Version FBSD_1.6 of that symbol appeared in FreeBSD 12.2, so if something complains about not finding this version, it's indeed an incomplete or b0rked base system upgrade.

As for how this can happen, I can only speculate: _Maybe_ freebsd-update(8) gets confused if you `fetch` before installing an `upgrade` completely (with 3 times `install`)?

To fix it, maybe redoing the upgrade with `--currently-running` set to 12.1 might do the trick, but that's just an untested idea (backup your data if you try).


----------



## SirDice (May 20, 2021)

Zirias said:


> Rebooting is unlikely to help,


The old version of the library could still be loaded. I like to reboot to make sure this doesn't happen.


----------



## zirias@ (May 20, 2021)

SirDice said:


> The old version of the library could still be loaded. I like to reboot to make sure this doesn't happen.


Correct, but this won't affect a newly started process.


----------



## ADH (May 21, 2021)

Zirias said:


> We've seen this problem quite a few times. SirDice is correct, though. This symbol version is definitely there in 12.2, I even tried to reproduce it in a VM, upgrading it to 12.2 with freebsd-update(8), and couldn't. So, your upgrade is somehow incomplete. Make sure you follow the procedure completely.


Thanks, I google the messages also find the similar problems post on the WEB and tried the solved methods, but it is no help. 

I followed the procedure of "Upgrading Using "FreeBSD Update" described in the https://www.freebsd.org/releases/12.2R/installation/ to install, upgrade the OS and reboot the system, but it is no help on this.


----------



## ADH (May 21, 2021)

Zirias said:


> Rebooting is unlikely to help, updating packages won't help with this for sure (although it will be necessary of course):
> 
> The symbol in question is in the threading library, which is part of base:
> 
> ...



The  `objdump -TC /usr/lib/libpthread.so | grep pthread_setname_np` shown nothing , it is different of yours,  maybe this is issue.


```
# find / -name libpthread.so
/usr/lib/libpthread.so
^C
# objdump -TC /usr/lib/libpthread.so | grep pthread_setname_np
#
# objdump -x /usr/lib/libpthread.so

/usr/lib/libpthread.so:     file format elf32-i386-freebsd
/usr/lib/libpthread.so
architecture: i386, flags 0x00000150:
HAS_SYMS, DYNAMIC, D_PAGED
start address 0x0000b000

Program Header:
    PHDR off    0x00000034 vaddr 0x00000034 paddr 0x00000034 align 2**2
         filesz 0x00000100 memsz 0x00000100 flags r--
    LOAD off    0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**12
         filesz 0x0000a0b0 memsz 0x0000a0b0 flags r--
    LOAD off    0x0000b000 vaddr 0x0000b000 paddr 0x0000b000 align 2**12
         filesz 0x000112f0 memsz 0x000112f0 flags r-x
    LOAD off    0x0001d000 vaddr 0x0001d000 paddr 0x0001d000 align 2**12
         filesz 0x0000136c memsz 0x0000b364 flags rw-
 DYNAMIC off    0x0001e230 vaddr 0x0001e230 paddr 0x0001e230 align 2**2
         filesz 0x000000d8 memsz 0x000000d8 flags rw-
   RELRO off    0x0001e000 vaddr 0x0001e000 paddr 0x0001e000 align 2**0
         filesz 0x0000036c memsz 0x0000036c flags r--
EH_FRAME off    0x0000666c vaddr 0x0000666c paddr 0x0000666c align 2**2
         filesz 0x00000a34 memsz 0x00000a34 flags r--
   STACK off    0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**0
         filesz 0x00000000 memsz 0x00000000 flags rw-

Dynamic Section:
  NEEDED      libc.so.7
  SONAME      libthr.so.3
  FLAGS_1     0x8
  REL         0x56b0
  RELSZ       0x528
  RELENT      0x8
  RELCOUNT    0x99
  JMPREL      0x5bd8
  PLTRELSZ    0x3a0
  PLTGOT      0x1d0e0
  PLTREL      0x11
  SYMTAB      0x134
  SYMENT      0x10
  STRTAB      0x34f4
  STRSZ       0x21bc
  GNU_HASH    0x1fe4
  HASH        0x27e4
  INIT_ARRAY  0x1e22c
  INIT_ARRAYSZ 0x4
  INIT        0x1bb80
  FINI        0x1bb94
  VERSYM      0x1b44
  VERDEF      0x1e88
  VERDEFNUM   0x9
  VERNEED     0x1f84
  VERNEEDNUM  0x1

Version definitions:
1 0x01 0x0f4779b3 libthr.so.3
2 0x00 0x077a28b0 FBSD_1.0
3 0x00 0x077a28b1 FBSD_1.1
4 0x00 0x077a28b2 FBSD_1.2
5 0x00 0x077a28b3 FBSD_1.3
6 0x00 0x077a28b4 FBSD_1.4
7 0x00 0x077a28b5 FBSD_1.5
8 0x00 0x077a28b6 FBSD_1.6
9 0x00 0x0f1efaa0 FBSDprivate_1.0

Version References:
  required from libc.so.7:
    0x077a28b0 0x00 10 FBSD_1.0
    0x077a28b1 0x00 13 FBSD_1.1
    0x077a28b2 0x00 14 FBSD_1.2
    0x077a28b3 0x00 12 FBSD_1.3
    0x0f1efaa0 0x00 11 FBSDprivate_1.0

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .dynsym       00001a10  00000134  00000134  00000134  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  1 .gnu.version  00000342  00001b44  00001b44  00001b44  2**1
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .gnu.version_d 000000fc  00001e88  00001e88  00001e88  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  3 .gnu.version_r 00000060  00001f84  00001f84  00001f84  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .gnu.hash     00000800  00001fe4  00001fe4  00001fe4  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  5 .hash         00000d10  000027e4  000027e4  000027e4  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  6 .dynstr       000021bc  000034f4  000034f4  000034f4  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  7 .rel.dyn      00000528  000056b0  000056b0  000056b0  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  8 .rel.plt      000003a0  00005bd8  00005bd8  00005bd8  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  9 .rodata       000006ec  00005f80  00005f80  00005f80  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 10 .eh_frame_hdr 00000a34  0000666c  0000666c  0000666c  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 11 .eh_frame     00003010  000070a0  000070a0  000070a0  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 12 .text         00010b80  0000b000  0000b000  0000b000  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 13 .init         00000011  0001bb80  0001bb80  0001bb80  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 14 .fini         0000000c  0001bb94  0001bb94  0001bb94  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 15 .plt          00000750  0001bba0  0001bba0  0001bba0  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 16 .data         000000e0  0001d000  0001d000  0001d000  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 17 .got.plt      000001dc  0001d0e0  0001d0e0  0001d0e0  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 18 .ctors        00000008  0001e000  0001e000  0001e000  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 19 .dtors        00000008  0001e008  0001e008  0001e008  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 20 .jcr          00000004  0001e010  0001e010  0001e010  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 21 .data.rel.ro  00000218  0001e014  0001e014  0001e014  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 22 .init_array   00000004  0001e22c  0001e22c  0001e22c  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 23 .dynamic      000000d8  0001e230  0001e230  0001e230  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 24 .got          00000064  0001e308  0001e308  0001e308  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 25 .bss          00009364  0001f000  0001f000  0001e36c  2**6
                  ALLOC
 26 .comment      000013ee  00000000  00000000  0001e36c  2**0
                  CONTENTS, READONLY
 27 .gnu_debuglink 00000018  00000000  00000000  0001f75a  2**0
                  CONTENTS, READONLY
SYMBOL TABLE:
no symbols


#
```


----------



## richardtoohey2 (May 21, 2021)

ADH said:


> I followed the procedure of Upgrading Using "FreeBSD Update" described in the https://www.freebsd.org/releases/12.2R/installation/ to install, upgrade the OS and reboot the system, but it is no help on this


So have many many other people - and those steps *work*.

But somehow not for everyone (including yourself), but I don't think anyone has got to the bottom of what goes wrong for a small group of upgraders.  If _that_ had been figured out, there would be a fix/workaround by now.


----------



## zirias@ (May 21, 2021)

richardtoohey2 said:


> But somehow not for everyone (including yourself), but I don't think anyone has got to the bottom of what goes wrong for a small group of upgraders. If _that_ had been figured out, there would be a fix/workaround by now.


Yes, how you get into this situation is unknown, I just _assume_ there could be a "user error" that somehow has this consequence, it could also be a well-hidden bug only triggered in some rare situations…

The only thing that's obvious is the result: The upgrade isn't complete. At least the threading library (probably other files as well) is still the one from 12.1.

I can think of one _safe_ method to fix it: Fetch the source for 12.2 (from the `releng/12.2` branch) and build and install it locally. The handbook explains how to do that as well, but it's a lengthy procedure.

Then, I'd have two ideas how to fix it that might or might not work correctly, so only try them when you have backups of everything important:

As described above, try to repeat the whole freebsd-update(8) procedure, giving a `--currently-running` flag with the `upgrade` subcommand, to convince the tool you're still on 12.1
Or maybe, grab the base.txz from a 12.2 installation medium and extract it over the system.

Side note just in case you weren't aware: There are tools for the same purpose as `nslookup` and `dig` in base, called host(1) and drill(1)


----------

