Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.85k stars 524 forks source link

After change in Solaris sockets perl now incorrectly reports an errror #22138

Closed vlmarek closed 2 weeks ago

vlmarek commented 2 weeks ago
$ cat test.pl
require IO::Socket::UNIX;
my $testfile = "/tmp/HKsPzZyjPz";
my $sock = new IO::Socket::UNIX(Local  => $testfile,
                                Listen => 1,);

die "Could not create UNIX domain socket: $!"
  unless defined $sock;

die "UNIX domain socket path was truncated"
  unless ($testfile eq $sock->hostpath());

print "Test OK\n";

This used to work, on recent Solaris it reports an error:

Bad arg length for Socket::unpack_sockaddr_un, length is 18, should be 110 at /usr/perl5/5.38/lib/i86pc-solaris-thread-multi-64/Socket.pm line 878.

Description Solaris used to have fixed size socket address length. And perl did compare that address lenght to sizeof(sockaddr_un). As seen in

https://github.com/Perl/perl5/blob/d15f6e9d45077d8ecabf346379f17906fdb9b061/cpan/Socket/Socket.xs#L954

But with recent change Solaris implementation started to behave the same as in Linux - that is the size is not predetermined, but instead silently drops any characters which do not fit into the structure. That means that the above mentioned test it now fails.

Instead it is needed to skip the check completely as it is done on Linux and others.

The line

938 # if defined(linux) || defined(CYGWIN) || defined(HAS_SOCKADDR_SA_LEN) has to be changed to 938 # if defined(linux) || defined(CYGWIN) || defined(sun) || defined(HAS_SOCKADDR_SA_LEN)

Should I create pull request for that?

Thank you __ Vlad

# perl -V output goes here
Summary of my perl5 (revision 5 version 38 subversion 2) configuration:

  Platform:
    osname=solaris
    osvers=2.11
    archname=i86pc-solaris-thread-multi-64
    uname='sunos u-build-2 5.11 11.4.69.166.0 i86pc i386 i86pc kvm '
    config_args='-de -Dmksymlinks -Ulocincpth= -Dbin=/usr/perl5/5.38/bin -Dcc=gcc -Dcf_by=perl-bugs -Dcf_email=first.last@example.invalid -Dlibperl=libperl.so -Duseshrplib -Dusedtrace -Duse64bitall -Dusethreads -Dmyhostname=localhost -Dmydomain=foobar.example.org -Dprefix=/usr/perl5/5.38 -Dprivlib=/usr/perl5/5.38/lib -Dsitelib=/usr/perl5/site_perl/5.38 -Dsiteprefix=/usr/perl5/5.38 -Dvendorlib=/usr/perl5/vendor_perl/5.38 -Dvendorprefix=/usr/perl5/5.38 -Dlibpth=/lib/64 /usr/lib/64 -Doptimize=-O3   '
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='gcc'
    ccflags ='-D_REENTRANT -m64 -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -D_LARGEFILE64_SOURCE -D_FORTIFY_SOURCE=2'
    optimize='-O3 '
    cppflags='-D_REENTRANT -m64 -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong'
    ccversion=''
    gccversion='13.2.0'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
 Linker and Libraries:
    ld='gcc'
    ldflags =' -m64 -fstack-protector-strong -L/usr/gnu/lib '
    libpth=/lib/64 /usr/lib/64 /usr/gcc/13/lib /usr/lib /usr/gnu/lib /usr/ccs/lib
    libs=-lpthread -lsocket -lnsl -lgdbm -ldb -ldl -lm -lc
    perllibs=-lpthread -lsocket -lnsl -ldl -lm -lc
    libc=/lib/libc.so
    so=so
    useshrplib=true
    libperl=libperl.so
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='  -R /usr/perl5/5.38/lib/i86pc-solaris-thread-multi-64/CORE'
    cccdlflags='-fPIC'
    lddlflags=' -shared -m64 -L/usr/gnu/lib -fstack-protector-strong'

Characteristics of this binary (from libperl):
  Compile-time options:
    HAS_LONG_DOUBLE
    HAS_STRTOLD
    HAS_TIMES
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_HASH_FUNC_SIPHASH13
    PERL_HASH_USE_SBOX32
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_SAFE_PUTENV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
    USE_REENTRANT_API
    USE_THREAD_SAFE_LOCALE
  Built under solaris
  Compiled at Mar 22 2024 14:47:42
  @INC:
    /usr/perl5/site_perl/5.38/i86pc-solaris-thread-multi-64
    /usr/perl5/site_perl/5.38
    /usr/perl5/vendor_perl/5.38/i86pc-solaris-thread-multi-64
    /usr/perl5/vendor_perl/5.38
    /usr/perl5/5.38/lib/i86pc-solaris-thread-multi-64
    /usr/perl5/5.38/lib
leonerd commented 2 weeks ago

This needs fixing upstream in Socket

vlmarek commented 2 weeks ago

Oh, silly me, thank you :)

vlmarek commented 2 weeks ago

Ah, I should not have closed the bug, merely reassing to Socket

vlmarek commented 2 weeks ago

Sorry, I don't see how to re-assign this ticket. Or change the queue

jkeenan commented 2 weeks ago

I have created https://rt.cpan.org/Ticket/Display.html?id=152866. @leonerd can you examine this there? Thanks.