DragonFlyBSD / DPorts

The dedicated application build system for DragonFly BSD
Other
89 stars 46 forks source link

net/libzmq4 give sigabort with IPv6 #208

Closed hxw closed 2 years ago

hxw commented 4 years ago

When using IPv6 socket with libzmq4 an assert is triggered in ip.cpp function:

void zmq::enable_ipv4_mapping (fd_t s_)

It is trying to perform the following:

setsockopt (s_, IPPROTO_IPV6, IPV6_V6ONLY,

Update the patch to configure to add the OpenBSD flag which appear to allow the code to run

libzmq.diff.txt

tuxillo commented 4 years ago

What's the assertion you are getting? It should be probably hitting errno_assert() after a failing setsockopt() call.

errno_assert (rc == 0);

Enabling ZMQ_HAVE_OPENBSD just bypass it all over.

hxw commented 4 years ago

This is the abort message when I use the pkg (i.e. brefore I enabled the OpenBSD flag)


Operation not supported (src/ip.cpp:141)
SIGABRT: abort
PC=0x801281c7c m=9 sigcode=0
```
hxw commented 4 years ago

Here is the result of a simple test program that I tried to replicate the situation to remiove the possibility of Go runtime being involved. The test is ok on FreeBSD but fais on DraginFly.

FreeBSD:

  2: socket fd:  3   rc:  -1  errno: 22
 28: socket fd:  3   rc:   0  errno: 0

DragonFly

  2: socket fd:  3   rc:  -1  errno: 22
 28: socket fd:  3   rc:  -1  errno: 45
% grep 45 /usr/include/errno.h 
#define EOPNOTSUPP  45      /* Operation not supported */

This is the test

#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#define SizeOfArray(a) (sizeof(a) / sizeof((a)[0]))
const int dom[] = {
    AF_INET,
    AF_INET6,
};
int main(int argc, char *argv[]) {
  for (size_t i = 0; i < SizeOfArray(dom); ++i) {
    int d = dom[i];
    const int s = socket(d, SOCK_STREAM, 0);
    printf("%3d: socket fd: %2d   ", d, s);
    int flag = 0;
    errno = 0;
    int rc = setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &flag, sizeof(flag));
    printf("rc: %3d  errno: %d\n", rc, errno);
    close(s);
  }
  return 1;
}
tuxillo commented 4 years ago

The fix in https://github.com/DragonFlyBSD/DeltaPorts/commit/2b99cb7d0634d5dc77ed6e45f68dce14bcf603c6 should do the trick too, can you please check and report back?

hxw commented 4 years ago

yes, this can work. Do you want me to file upstream bug with libzmq for this?

tuxillo commented 2 years ago

Yeah, it could be upstreamed I guess.