Nslookup ipv6 in lede 17.01.1 (fix: update busybox to 1.25.1-4)

I think this was working earlier for me, but nslookup on the router doesn't return ipv6 addresses any more. As a result of that the ddns scripts for ipv6 are partially broken. They can update the ddns, but they cannot verify the ipv6 address for the domain. Did something change in the latest lede release ? The scripts try to call "/usr/bin/nslookup domain.com" which only returns ipv4. In the changelog, I see "busybox: add musl compatible nslookup replacement". Is it related ?

I did see this commit from 3 days ago that may be related.

Try nslookup -q=ANY google.com or nslookup -q=AAAA google.com or nslookup -q=A -q=AAAA google.com

root@LEDE:~# nslookup -q=ANY google.com
Illegal instruction
root@LEDE:~# nslookup -q=AAAA google.com
Illegal instruction
root@LEDE:~# nslookup -q=A -q=AAAA google.com
Segmentation fault

On which device / target did you observe that error and does it happen without -q flag as well?

On ar7xx / gcc 6.3.0 binutils 2.8 march 24kc archer c7 v2
I get this:

root@LEDE:~# nslookup -q=ANY google.com
Bus error
root@LEDE:~# nslookup -q=AAAA google.com
Bus error
root@LEDE:~# nslookup -q=A -q=AAAA google.com
Bus error

Here strace if its help

[details=Summary]root@LEDE:~# strace -d nslookup -q=AAAA google.com
strace: ptrace_setoptions = 0x51
strace: new tcb for pid 4498, active tcbs:1
strace: [wait(0x80177f) = 4498] WIFSTOPPED,sig=SIGSTOP,EVENT_STOP (128)
strace: pid 4498 has TCB_STARTUP, initializing it
strace: [wait(0x80057f) = 4498] WIFSTOPPED,sig=SIGTRAP,EVENT_STOP (128)
strace: [wait(0x00197f) = 4498] WIFSTOPPED,sig=SIGCONT
strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
execve("/usr/bin/nslookup", ["nslookup", "-q=AAAA", "google.com"], [/* 12 vars */]strace: [wait(0x04057f) = 4498] WIFSTOPPED,sig=SIGTRAP,EVENT_EXEC (4)
strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
) = 0
strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
set_thread_area(0x774acd50strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
) = 0
strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
set_tid_address(0x774a5cb4strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
) = 4498
strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
open("/etc/ld-musl-mips-sf.path", O_RDONLY|O_LARGEFILE|O_CLOEXECstrace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
) = -1 ENOENT (No such file or directory)
strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
open("/lib/libgcc_s.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXECstrace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
) = 3
strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
fcntl64(3, F_SETFD, FD_CLOEXECstrace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
) = 0
strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
fstat64(3, strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
{st_mode=S_IFREG|0644, st_size=76496, ...}) = 0
strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
read(3, strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
"\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\10\0\0\0\1\0\0(\0\0\0\0004"..., 936) = 936
strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
mmap2(NULL, 143360, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
) = 0x773da000
strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
mmap2(0x773fc000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x12000strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
) = 0x773fc000
strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
close(3strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
) = 0
strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
getuid(strace: [wait(0x00857f) = 4498] WIFSTOPPED,sig=133
) = 0
strace: [wait(0x000a7f) = 4498] WIFSTOPPED,sig=SIGBUS
--- SIGBUS {si_signo=SIGBUS, si_code=SI_KERNEL, si_addr=NULL} ---
strace: [wait(0x06057f) = 4498] WIFSTOPPED,sig=SIGTRAP,EVENT_EXIT (6)
strace: [wait(0x00000a) = 4498] WIFSIGNALED,sig=SIGBUS
+++ killed by SIGBUS +++
strace: dropped tcb for pid 4498, 0 remain
Bus error[/details]

[details=Summary]root@LEDE:~# strace -d nslookup google.com
strace: ptrace_setoptions = 0x51
strace: new tcb for pid 4501, active tcbs:1
strace: [wait(0x80177f) = 4501] WIFSTOPPED,sig=SIGSTOP,EVENT_STOP (128)
strace: pid 4501 has TCB_STARTUP, initializing it
strace: [wait(0x80057f) = 4501] WIFSTOPPED,sig=SIGTRAP,EVENT_STOP (128)
strace: [wait(0x00197f) = 4501] WIFSTOPPED,sig=SIGCONT
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
execve("/usr/bin/nslookup", ["nslookup", "google.com"], [/* 12 vars */]strace: [wait(0x04057f) = 4501] WIFSTOPPED,sig=SIGTRAP,EVENT_EXEC (4)
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 0
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
set_thread_area(0x77c1cd50strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 0
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
set_tid_address(0x77c15cb4strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 4501
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
open("/etc/ld-musl-mips-sf.path", O_RDONLY|O_LARGEFILE|O_CLOEXECstrace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = -1 ENOENT (No such file or directory)
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
open("/lib/libgcc_s.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXECstrace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 3
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
fcntl64(3, F_SETFD, FD_CLOEXECstrace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 0
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
fstat64(3, strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
{st_mode=S_IFREG|0644, st_size=76496, ...}) = 0
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
read(3, strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
"\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\10\0\0\0\1\0\0(\0\0\0\0004"..., 936) = 936
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
mmap2(NULL, 143360, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 0x77b4a000
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
mmap2(0x77b6c000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x12000strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 0x77b6c000
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
close(3strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 0
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
getuid(strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 0
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
clock_gettime(CLOCK_REALTIME, strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
{tv_sec=1493051955, tv_nsec=18127421}) = 0
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
open("/etc/resolv.conf", O_RDONLY|O_LARGEFILEstrace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 3
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
readv(3, strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
[{iov_base="", iov_len=0}, {iov_base="search lan\nnameserver 127.0.0.1\n", iov_len=1024}], 2) = 32
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
readv(3, strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
[{iov_base="", iov_len=0}, {iov_base="", iov_len=1024}], 2) = 0
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
close(3strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 0
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IPstrace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 3
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
bind(3, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("0.0.0.0")}, 16strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 0
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
clock_gettime(CLOCK_REALTIME, strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
{tv_sec=1493051955, tv_nsec=25146750}) = 0
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
sendto(3, "\233Q\1\0\0\1\0\0\0\0\0\0\6google\3com\0\0\1\0\1", 28, MSG_NOSIGNAL, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, 16strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 28
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
poll([{fd=3, events=POLLIN}], 1, 2500strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 1 ([{fd=3, revents=POLLIN}])
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
recvfrom(3, strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
"\233Q\201\200\0\1\0\3\0\0\0\0\6google\3com\0\0\1\0\1\300\f\0\1"..., 512, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, [16]) = 76
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
clock_gettime(CLOCK_REALTIME, strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
{tv_sec=1493051955, tv_nsec=51556119}) = 0
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
ioctl(1, _IOC(_IOC_READ, 0x74, 0x68, 0x08)strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
, 0x7f8d1784) = 0
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
writev(1, [{iov_base="Server:\t\t127.0.0.1", iov_len=18}, {iov_base="\n", iov_len=1}], 2Server: 127.0.0.1
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 19
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
writev(1, [{iov_base="Address:\t127.0.0.1#53", iov_len=21}, {iov_base="\n", iov_len=1}], 2Address: 127.0.0.1#53
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 22
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
writev(1, [{iov_base="", iov_len=0}, {iov_base="\n", iov_len=1}], 2
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 1
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
writev(1, [{iov_base="", iov_len=0}, {iov_base="Non-authoritative answer:\n", iov_len=26}], 2Non-authoritative answer:
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 26
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
writev(1, [{iov_base="Name:\tgoogle.com", iov_len=16}, {iov_base="\n", iov_len=1}], 2Name: google.com
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 17
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
writev(1, [{iov_base="Address: 172.217.21.238", iov_len=23}, {iov_base="\n", iov_len=1}], 2Address: 172.217.21.238
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 24
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
writev(1, [{iov_base="Name:\tgoogle.com", iov_len=16}, {iov_base="\n", iov_len=1}], 2Name: google.com
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 17
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
writev(1, [{iov_base="Address: 172.217.21.238", iov_len=23}, {iov_base="\n", iov_len=1}], 2Address: 172.217.21.238
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 24
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
writev(1, [{iov_base="Name:\tgoogle.com", iov_len=16}, {iov_base="\n", iov_len=1}], 2Name: google.com
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 17
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
writev(1, [{iov_base="Address: 172.217.21.238", iov_len=23}, {iov_base="\n", iov_len=1}], 2Address: 172.217.21.238
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 24
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
writev(1, [{iov_base="", iov_len=0}, {iov_base="\n", iov_len=1}], 2
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
) = 1
strace: [wait(0x00857f) = 4501] WIFSTOPPED,sig=133
exit_group(0strace: [wait(0x06057f) = 4501] WIFSTOPPED,sig=SIGTRAP,EVENT_EXIT (6)
) = ?
strace: [wait(0x000000) = 4501] WIFEXITED,exitcode=0
+++ exited with 0 +++
strace: dropped tcb for pid 4501, 0 remain
root@LEDE:~#[/details]

This is on bcm53xx (specifically asus ac68u). It works without the -q flag.

I got the same "Illegal instruction" and "Segmentation fault" errors on a WRT3200ACM with 17.01.1

Even without -q flag?

Error only appears when using the "-q" option:
root@router:~# nslookup -q=ANY google.com
Illegal instruction
root@router:~# nslookup google.com
Server: 127.0.0.1
Address: 127.0.0.1#53

Non-authoritative answer:
Name:	google.com
Address: 216.58.211.206
Name:	google.com
Address: 216.58.211.206
Name:	google.com
Address: 216.58.211.206

I am unable to reproduce it on another ar71xx device using the default snapshots, it might be gcc 6 related.

Hm, maybe it happens because we're writing into argv. Please try leaving out the equal sign, e.g. nslookup -q ANY google.com - is it working without crash then?

I get a variant of the error with master r3995: "ANY" fails, but A and AAAA and no q work.
(Same result with both R7800/ipq806x and WNDR3700/ar71xx)

And I do get the "Illegal instruction" with R7800 with a new 17.01 build, default toolchain.

17.01:

Reboot (17.01-SNAPSHOT, r3326-1ab41265c3)

root@LEDE:~# nslookup -q=ANY google.com
Illegal instruction
root@LEDE:~# nslookup  google.com
Server:         127.0.0.1
Address:        127.0.0.1#53

Non-authoritative answer:
Name:   google.com
Address: 62.165.157.19
...

root@LEDE:~# nslookup -q=A google.com
Illegal instruction
root@LEDE:~# nslookup -q=AAAA google.com
Illegal instruction

MASTER:

root@LEDE:~# nslookup -q=ANY google.com
Server:         127.0.0.1
Address:        127.0.0.1#53

Non-authoritative answer:
*** Can't find google.com: No answer

root@LEDE:~# nslookup  google.com
Server:         127.0.0.1
Address:        127.0.0.1#53

Non-authoritative answer:
Name:   google.com
Address: 62.165.157.17
...

root@LEDE:~# nslookup -q=A google.com
Server:         127.0.0.1
Address:        127.0.0.1#53

Non-authoritative answer:
Name:   google.com
Address: 62.165.157.17
...

root@LEDE:~# nslookup -q=AAAA google.com
Server:         127.0.0.1
Address:        127.0.0.1#53

Non-authoritative answer:
google.com      has AAAA address 2a00:1450:4013:c06::8b

@hnyman - please try without equal sign after -q, e.g. -q ANY

Same result:

root@LEDE:~# nslookup -q AAAA google.com
Illegal instruction
root@LEDE:~# nslookup -q A google.com
Illegal instruction
root@LEDE:~# nslookup -q ANY google.com
Illegal instruction
root@LEDE:~# nslookup  google.com
Server:         127.0.0.1
Address:        127.0.0.1#53

Non-authoritative answer:
Name:   google.com
Address: 172.217.22.174
Name:   google.com
Address: 172.217.22.174
Name:   google.com
Address: 172.217.22.174

Will need a gdb backtrace then to narrow down the result. I cannot reproduce the error on any hardware I own or on any of the emulated mips or arm targets.

Hopefully this helps.

Reading symbols from ./staging_dir/target-arm_cortex-a15+neon-vfpv4_musl-1.1.16_eabi/root-ipq806x/bin/busybox...done.
0xb6fdd770 in _dlstart ()
   from /OwrtLEDE/r7800-1701/scripts/../staging_dir/target-arm_cortex-a15+neon-vfpv4_musl-1.1.16_eabi/root-ipq806x/lib/ld-musl-armhf.so.1
(gdb) c
Continuing.

Program received signal SIGILL, Illegal instruction.
free (p=0xbefffede) at src/malloc/malloc.c:465
465			if (extra & 1) a_crash();
(gdb) bt
#0  free (p=0xbefffede) at src/malloc/malloc.c:465
#1  0x0005ca54 in llist_pop (head=head@entry=0xbefffccc) at libbb/llist.c:44
#2  0x0002035c in nslookup_main (argc=argc@entry=4, argv=argv@entry=0xbefffdd4)
    at networking/nslookup_lede.c:744
#3  0x00017330 in run_applet_no_and_exit (applet_no=64, argv=0xbefffdd4, 
    argv@entry=0x4) at libbb/appletlib.c:879
#4  0x000173d8 in run_applet_and_exit (argv=0x4, 
    name=0x40 <error: Cannot access memory at address 0x40>)
    at libbb/appletlib.c:893
#5  main (argc=<optimized out>, argv=0x4) at libbb/appletlib.c:971
(gdb) thread apply all bt full

Can you single step through the while (type_strings) loop and dump the value and address of ptr and type_strings after each iteration?

I will continue experimenting.

(gdb) break networking/nslookup_lede.c:744
Breakpoint 1 at 0x20350: file networking/nslookup_lede.c, line 744.
(gdb) c
Continuing.

Breakpoint 1, nslookup_main (argc=argc@entry=4, argv=argv@entry=0xbefffdd4)
    at networking/nslookup_lede.c:744
744			ptr = llist_pop(&type_strings);
(gdb) break networking/nslookup_lede.c:767
Breakpoint 2 at 0x203bc: file networking/nslookup_lede.c, line 767.
(gdb) c
Continuing.

Program received signal SIGILL, Illegal instruction.
free (p=0xbefffede) at src/malloc/malloc.c:465
465			if (extra & 1) a_crash();
(gdb)

The crash seems to be caused by an attempt to free() something which resides on the stack and not on the heap but I have no idea what and why. The llist items are all supposed to be allocated dynamically. Can you dump type_strings (p *type_strings in gdb) just before the llist_pop() call?