https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90718

            Bug ID: 90718
           Summary: libphobos.phobos_shared/std/socket.d FAILs on 32-bit
                    Solaris/SPARC
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: d
          Assignee: ibuclaw at gdcproject dot org
          Reporter: ro at gcc dot gnu.org
  Target Milestone: ---
            Target: sparc*-*-solaris2.11

The libphobos.phobos_shared/std/socket.d test FAILs on 32-bit Solaris/SPARC:

Thread 2 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1 (LWP 1)]
0x00043eb4 in std.socket.getAddressInfoImpl(const(char[]), const(char[]),
core.sys.posix.netdb.addrinfo*) (node=..., service=..., hints=0xffbfddd4)
    at
/vol/gcc/src/hg/trunk/solaris/libphobos/testsuite/../src/std/socket.d:1006
1006                    cast(AddressFamily) ai.ai_family,

1: x/i $pc
=> 0x43eb4
<_D3std6socket18getAddressInfoImplFxAaxAaPS4core3sys5posix5netdb8addrinfoZAS3std6socket11AddressInfo+504>:
  ld  [ %g1 + 4 ], %g1
(gdb) p/x $g1
$1 = 0x21

The first time through, ai is

$9 = {ai_flags = 0, ai_family = 2, ai_socktype = 0, ai_protocol = 0, 
  _ai_pad = 16, ai_addrlen = 0, ai_canonname = 0xac710 "", ai_addr = 0xac4c0, 
  ai_next = 0x21}

i.e. ai_next is bogus.

Comparing the struct addrinfo declarations in <netdb.h>

struct addrinfo {
        int ai_flags;           /* AI_PASSIVE, AI_CANONNAME, ... */
        int ai_family;          /* PF_xxx */
        int ai_socktype;        /* SOCK_xxx */
        int ai_protocol;        /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
#ifdef __sparcv9
        int _ai_pad;            /* for backwards compat with old size_t */
#endif /* __sparcv9 */
        socklen_t ai_addrlen;
        char *ai_canonname;     /* canonical name for hostname */
        struct sockaddr *ai_addr;       /* binary address */
        struct addrinfo *ai_next;       /* next structure in linked list */
};

and libdruntime/core/sys/posix/netdb.d

    struct addrinfo
    {
        int ai_flags;
        int ai_family;
        int ai_socktype;
        int ai_protocol;

        version (SPARC)
            int _ai_pad;
        else version (SPARC64)
            int _ai_pad;

        socklen_t ai_addrlen;
        char* ai_canonname;
        sockaddr* ai_addr;
        addrinfo* ai_next;
    }

There's a mismatch here: the system version has no _ai_pad member on 32-bit
SPARC; no idea how this crept into the druntime version.

Fixing as in the attached patch lets the test get further along.  It still
FAILs
however:

Aborting from
/vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/gcc/sections/elf_shared.d(724)
DSO already registered.

but this is a different issue affecting a couple of other tests as well.

Reply via email to