How do I debug a Segmentation fault from ntpmon?

Fred Wright fw at fwright.net
Sat Jun 20 21:08:41 UTC 2026


On Fri, 19 Jun 2026, Hal Murray via devel wrote:

>> 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

I don't know what you mean by "interrupt".

If you mean hardware interrupt, an interrupt handler trashing a register 
would be a really severe OS bug, and it almost certainly wouldn't be 
confined to your program.

If you mean signal, then yes, signal handlers can trash registers, but 
they have to go out of their way to do so, and it doesn't seem that likely 
that a signal is involved, anyway.

If you mean context switch, then that could matter with multiple threads, 
but Python doesn't use multiple threads unless you explicitly use a 
multithreading feature.

What changed since the last time it worked?

If the failure happens reasonably quickly, it would be practical to narrow 
it down by bisecting it (as long as there aren't too many potholes in the 
history).

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

Fred Wright


More information about the devel mailing list