How do I debug a Segmentation fault from ntpmon?

Hal Murray halmurray at sonic.net
Sat Jun 20 03:39:37 UTC 2026


> Maybe strace to see what ssyscall is adjacent.

There is probably an interrupt coming through.


I've got one from ntpd in gdb.

It's writing a rawstats line.  It needs a string for the remote address.

socktoa_r get passed a pointer to a sockaddr_u which is a union of 
sockaddr, sockaddr_in and sockaddr_in6
They all have some common stuff up front and then an address.  That common 
stuff includes an address type (called family)

The code in libntp/socktoa.c does a switch on AF(sock)
The AF_INET6 path does:
   inet_ntop(AF_INET6, PSOCK_ADDR6(sock), buf, buflen);
Note that the first parameter is a constant.
AF_INET6 is 10 (decimal)

#3  __inet_ntop (af=<optimized out>, af at entry=28, src=src at entry=0x414b4378,

    dst=dst at entry=0x281c40 <lib_getbuf.lib_stringbuf+1408> "", 
    size=size at entry=128) at /usr/src/lib/libc/inet/inet_ntop.c:59
59	in /usr/src/lib/libc/inet/inet_ntop.c
Note that af, the first parametr is 28.

It's now 28 in the sock parameter to socktoa_r

I'm guessing something like this:
  code does the switch and decides to take the IPv6 path.
  interrupt happens, trashes a register
  compiler notices that it already has AF_INET6 in the right register
  inet_ntop does a similar switch, so it got called with 10 but now has 28

Mumble.  Time to see if I can find the right FreeBSD mailing list.



-- 
These are my opinions.  I hate spam.





More information about the devel mailing list