Dear Maintainer,
I just tried to reproduce the crash but did not get it.
Maybe some more details of the configuration details of
host.cfg and DNS server setup could help,
because in my test I never reached with my IPv6 config
the faulting instruction.

At least the instruction, at that address where the segfault is received,
leads to the assumption that hent->h_addr_list is not a valid pointer
for some reason.


A workaround could be to check if the DNS result is IPv4.
I guess following could achieve this:
dns.c:119:
-       if (status == ARES_SUCCESS) {
+       if (status == ARES_SUCCESS && hent->h_addrtype == AF_INET && 
hent->h_addr_list) {


But more insight could maybe give someone experiencing the crash
by forwarding the output of following in the dns_simple_callback frame:

    print *hent
    x/1gx *(hent->h_addr_list)
    x/4ub *(hent->h_addr_list)

And maybe a 'bt full' should contain a part of the UDP response.


Kind regards,
Bernhard



(gdb) disassemble /m dns_simple_callback
Dump of assembler code for function dns_simple_callback:
111     {
   0x0000555555569ab0 <+0>:     push   %r13
   0x0000555555569ab2 <+2>:     push   %r12
   0x0000555555569ab4 <+4>:     mov    %rcx,%r13                                
                            # store address of hent into $r13
   0x0000555555569ab7 <+7>:     push   %rbp
   0x0000555555569ab8 <+8>:     push   %rbx
   0x0000555555569ab9 <+9>:     mov    %rdi,%rbx
   0x0000555555569abc <+12>:    mov    %esi,%ebp
   0x0000555555569abe <+14>:    sub    $0x28,%rsp
   0x0000555555569ac5 <+21>:    mov    %fs:0x28,%rax
   0x0000555555569ace <+30>:    mov    %rax,0x18(%rsp)
   0x0000555555569ad3 <+35>:    xor    %eax,%eax

112             struct dnsitem_t *dnsc = (dnsitem_t *)arg;
113             struct timespec etime;
114
115             getntimer(&etime);
   0x0000555555569ac2 <+18>:    mov    %rsp,%rdi
   0x0000555555569ad5 <+37>:    callq  0x55555556c030 <getntimer>

116             tvdiff(&dnsc->resolvetime, &etime, &dnsc->resolvetime);
   0x0000555555569ada <+42>:    lea    0x20(%rbx),%rdi
   0x0000555555569ade <+46>:    mov    %rsp,%rsi
   0x0000555555569ae1 <+49>:    mov    %rdi,%rdx
   0x0000555555569ae4 <+52>:    callq  0x555555578790 <tvdiff>

117             pending_dns_count--;
   0x0000555555569ae9 <+57>:    subl   $0x1,0x2287d8(%rip)        # 
0x5555557922c8 <pending_dns_count>

118
119             if (status == ARES_SUCCESS) {
   0x0000555555569af0 <+64>:    test   %ebp,%ebp
   0x0000555555569af2 <+66>:    jne    0x555555569b30 <dns_simple_callback+128>

120                     memcpy(&dnsc->addr, *(hent->h_addr_list), 
sizeof(dnsc->addr));
   0x0000555555569af4 <+68>:    mov    0x18(%r13),%rax                          
                            # store address hent->h_addr_list points to into 
$rax

121                     dbgprintf("Got DNS result for host %s : %s\n", 
dnsc->name, inet_ntoa(dnsc->addr));
   0x0000555555569af8 <+72>:    mov    0x228dc2(%rip),%edx        # 
0x5555557928c0 <debug>
   0x0000555555569afe <+78>:    mov    (%rax),%rax
   0x0000555555569b01 <+81>:    test   %edx,%edx
=> 0x0000555555569b03 <+83>:    mov    (%rax),%edi                              
                            # store address pointed to by hent->h_addr into $edi
   0x0000555555569b08 <+88>:    jne    0x555555569b88 <dns_simple_callback+216>


(gdb) print/x $r13
$27 = 0x5555557bd4d0
(gdb) print hent
$28 = (struct hostent *) 0x5555557bd4d0

(gdb) x/1xg $r13 + 0x18
0x5555557bd4e8: 0x00005555557a8560
(gdb) print hent->h_addr_list
$32 = (char **) 0x5555557a8560

(gdb) x/1xg hent->h_addr_list
0x5555557a8560: 0x00005555557a8220
(gdb) print/x $rax
$33 = 0x5555557a8220

(gdb) x/4ub *(hent->h_addr_list)
0x5555557a8220: 192     168     240     240

Reply via email to