Created attachment 174083 [details] Simple program that illustrates the bug FreeBSD 10.3-RELEASE-p4: While messing with UNIX-domain sockets (AF_LOCAL), I've noticed that the listen() system call succeeds for a locally bound datagram-oriented (SOCK_DGRAM) socket on FreeBSD while legitimately failing on other systems since datagram sockets can't be in a listening state. Seemed like not a big deal first but eventually led to some undefined behaviour (which I wasn't able to reproduce as a separate test-case unfortunately). Nevertheless, expected behaviour would be to fail with EOPNOTSUPP or a similar error code. Also, please note that no such unexpected behaviour is observed for UDP sockets (AF_INET and AF_INET6). The bug seems to affect only UNIX sockets (AF_LOCAL). See attached a simple program that illustrates the bug.
This was fixed by glebius@ here: https://cgit.freebsd.org/src/commit/?id=beb4b312004b -- the fix is in all supported releases.