[erlang-questions] Re: Erlang/OTP R14B01 has been released

Raimo Niskanen raimo+erlang-questions@REDACTED
Tue Dec 14 09:44:08 CET 2010


On Mon, Dec 13, 2010 at 09:38:14PM +0100, Boris Mühmer wrote:
> Am Montag, den 13.12.2010, 19:49 +0100 schrieb Boris Mühmer:
> > Core was generated by `/opt/erlang-otp/lib/erlang/erts-5.8.2/bin/beam.smp -- -root /opt/erlang-otp/lib'.
> > Program terminated with signal 11, Segmentation fault.
> > #0  0x0000000000577ba2 in inet_ctl_getifaddrs (desc=<value optimized out>, cmd=<value optimized out>, 
> >     buf=<value optimized out>, len=0, rbuf=<value optimized out>, rsize=<value optimized out>)
> >     at drivers/common/inet_drv.c:4948
> > 4948		if (ifa_p->ifa_addr->sa_family == AF_INET
> 
> I checked one more thing:
> 
> (gdb) l
> 4943		utf8_encode(ifa_p->ifa_name, -1, buf_p);
> 4944		buf_p += len;
> 4945		*buf_p++ = '\0';
> 4946		*buf_p++ = INET_IFOPT_FLAGS;
> 4947		put_int32(IFGET_FLAGS(ifa_p->ifa_flags), buf_p); buf_p += 4;
> 4948		if (ifa_p->ifa_addr->sa_family == AF_INET
> 4949	#if defined(AF_INET6)
> 4950		    || ifa_p->ifa_addr->sa_family == AF_INET6
> 4951	#endif
> 4952		    ) {
> (gdb) p ifa_p
> $1 = (struct ifaddrs *) 0x2853d20
> (gdb) p ifa_p->ifa_addr
> $2 = (struct sockaddr *) 0x0
> 
> Hmmm... well, then statement
> 
> if (ifa_p->ifa_addr->sa_family == AF_INET
> 
> will "of course" fail.
> 
> The "offending" device is:
> 
> (gdb) p ifa_p->ifa_name
> $7 = 0x2853dc4 "tun0"
> 
> The "OpenVPN" device.

Good hunting!

The man page for getifaddrs() says:
    The ifa_addr field references either the address of the interface or
    the link level address of the interface, if one exists, otherwise it
    is NULL.  (The sa_family field of the ifa_addr field should be
    consulted to determine the format of the ifa_addr address.)

And I missed the fact that the address could be NULL entirely...
Silly me. The same goes for many other fields too.
Can you test the attached patch to see if it is this problem
only or more. It is really just a 6-line change, but whitespace
differences makes it ugly.

> 
> 
>   - boris
> 

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB
-------------- next part --------------
A non-text attachment was scrubbed...
Name: getifaddrs.diff
Type: text/x-patch
Size: 2336 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20101214/77f47015/attachment.bin>


More information about the erlang-questions mailing list