Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed test dist/IO/t/cachepropagate-unix on OS X with Perl 5.22 (regression from 5.20) #15310

Closed
p5pRT opened this issue May 7, 2016 · 19 comments

Comments

@p5pRT
Copy link

p5pRT commented May 7, 2016

Migrated from rt.perl.org#128095 (status was 'resolved')

Searchable as RT128095$

@p5pRT
Copy link
Author

p5pRT commented May 7, 2016

From mojca@macports.org

Since Perl 5.22 (I only tested 5.22.1 and 5.22.2) I'm experiencing a
problem that wasn't present on 5.20.3.

dist/IO/t/cachepropagate-unix .................................
# Failed test 'datagram socket created'
# at t/cachepropagate-unix.t line 75.
Can't call method "protocol" on an undefined value at
t/cachepropagate-unix.t line 77.
# Looks like you planned 15 tests but ran 9.
# Looks like you failed 1 test of 9 run.
# Looks like your test exited with 48 just after 9.
FAILED at test 9

This happens on Mac OS X (I tested on 10.7, but is most likely present
on others as well) and with a MacPorts build.

I opened a ticket at
  https://trac.macports.org/ticket/51327

See also ticket #128093.
I will try to test whether there is any difference if I change some
compiler flags or if I build Perl outside of the distribution.

Mojca

@p5pRT
Copy link
Author

p5pRT commented May 8, 2016

From @jkeenan

On Sat May 07 07​:40​:21 2016, mojca@​macports.org wrote​:

Since Perl 5.22 (I only tested 5.22.1 and 5.22.2) I'm experiencing a
problem that wasn't present on 5.20.3.

dist/IO/t/cachepropagate-unix .................................
# Failed test 'datagram socket created'
# at t/cachepropagate-unix.t line 75.
Can't call method "protocol" on an undefined value at
t/cachepropagate-unix.t line 77.
# Looks like you planned 15 tests but ran 9.
# Looks like you failed 1 test of 9 run.
# Looks like your test exited with 48 just after 9.
FAILED at test 9

This happens on Mac OS X (I tested on 10.7, but is most likely present
on others as well) and with a MacPorts build.

I opened a ticket at
https://trac.macports.org/ticket/51327

See also ticket #128093.
I will try to test whether there is any difference if I change some
compiler flags or if I build Perl outside of the distribution.

Mojca

Please attach to this story the results of 'perl -V' performed in the build where you experienced this problem.

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented May 8, 2016

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented May 9, 2016

From mojca.miklavec.lists@gmail.com

Dne Ned 08 Maj 2016 08​:13​:11 je jkeenan napisal​:

Please attach to this story the results of 'perl -V' performed in the
build where you experienced this problem.

Thank you very much.

$ perl5.22 -V
Summary of my perl5 (revision 5 version 22 subversion 2) configuration​:
 
  Platform​:
  osname=darwin, osvers=11.4.2, archname=darwin-thread-multi-2level
  uname='darwin smurfette.local 11.4.2 darwin kernel version 11.4.2​: thu aug 23 16​:25​:48 pdt 2012; root​:xnu-1699.32.7~1release_x86_64 x86_64 '
  config_args='-des -Dprefix=/opt/local -Dscriptdir=/opt/local/bin -Dcppflags=-I/opt/local/include -Dccflags=-pipe -Os -Dldflags=-L/opt/local/lib -Wl,-headerpad_max_install_names -Dvendorprefix=/opt/local -Dusemultiplicity=y -Dusethreads -Duseshrplib -Dcc=/usr/bin/clang -Dld=env MACOSX_DEPLOYMENT_TARGET=10.7 /usr/bin/clang -Dman1ext=1pm -Dman3ext=3pm -Dman1dir=/opt/local/share/man/man1p -Dman3dir=/opt/local/share/man/man3p -Dsitebin=/opt/local/libexec/perl5.22/sitebin -Dsiteman1dir=/opt/local/share/perl5.22/siteman/man1 -Dsiteman3dir=/opt/local/share/perl5.22/siteman/man3 -Dvendorbin=/opt/local/libexec/perl5.22 -Dvendorman1dir=/opt/local/share/perl5.22/man/man1 -Dvendorman3dir=/opt/local/share/perl5.22/man/man3 -Dpager=/usr/bin/less -sR -Dperlpath=/opt/local/bin/perl5.22 -Dstartperl=#!/opt/local/bin/perl5.22'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=define, usemultiplicity=define
  use64bitint=define, use64bitall=define, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='/usr/bin/clang', ccflags ='-pipe -Os -fno-common -DPERL_DARWIN -I/opt/local/include -fno-strict-aliasing -fstack-protector -I/opt/local/include -DPERL_USE_SAFE_PUTENV',
  optimize='-O3',
  cppflags='-I/opt/local/include -pipe -Os -fno-common -DPERL_DARWIN -I/opt/local/include -fno-strict-aliasing -fstack-protector -I/opt/local/include'
  ccversion='', gccversion='4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)', 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='env MACOSX_DEPLOYMENT_TARGET=10.7 /usr/bin/clang', ldflags ='-L/opt/local/lib -Wl,-headerpad_max_install_names -fstack-protector'
  libpth=/opt/local/lib /usr/local/lib /usr/bin/../lib/clang/4.2/lib /usr/lib
  libs=-lpthread -lgdbm -ldbm -ldl -lm -lutil -lc
  perllibs=-lpthread -ldl -lm -lutil -lc
  libc=, so=dylib, useshrplib=true, libperl=libperl.dylib
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
  cccdlflags=' ', lddlflags='-L/opt/local/lib -Wl,-headerpad_max_install_names -bundle -undefined dynamic_lookup -fstack-protector'

Characteristics of this binary (from libperl)​:
  Compile-time options​: HAS_TIMES MULTIPLICITY PERLIO_LAYERS
  PERL_DONT_CREATE_GVSV
  PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
  PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
  PERL_NEW_COPY_ON_WRITE 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
  Built under darwin
  Compiled at May 6 2016 13​:39​:48
  @​INC​:
  /opt/local/lib/perl5/site_perl/5.22/darwin-thread-multi-2level
  /opt/local/lib/perl5/site_perl/5.22
  /opt/local/lib/perl5/vendor_perl/5.22/darwin-thread-multi-2level
  /opt/local/lib/perl5/vendor_perl/5.22
  /opt/local/lib/perl5/5.22/darwin-thread-multi-2level
  /opt/local/lib/perl5/5.22
  .

$ perl5.24 -V
Summary of my perl5 (revision 5 version 24 subversion 0) configuration​:
 
  Platform​:
  osname=darwin, osvers=11.4.2, archname=darwin-thread-multi-2level
  uname='darwin smurfette.local 11.4.2 darwin kernel version 11.4.2​: thu aug 23 16​:25​:48 pdt 2012; root​:xnu-1699.32.7~1release_x86_64 x86_64 '
  config_args='-des -Dprefix=/opt/local -Dscriptdir=/opt/local/bin -Dcppflags=-I/opt/local/include -Dldflags=-L/opt/local/lib -Wl,-headerpad_max_install_names -Dvendorprefix=/opt/local -Dusemultiplicity=y -Dusethreads -Duseshrplib -Dcc=/usr/bin/clang -Dld=env MACOSX_DEPLOYMENT_TARGET=10.7 /usr/bin/clang -Dman1ext=1pm -Dman3ext=3pm -Dman1dir=/opt/local/share/man/man1p -Dman3dir=/opt/local/share/man/man3p -Dsitebin=/opt/local/libexec/perl5.24/sitebin -Dsiteman1dir=/opt/local/share/perl5.24/siteman/man1 -Dsiteman3dir=/opt/local/share/perl5.24/siteman/man3 -Dvendorbin=/opt/local/libexec/perl5.24 -Dvendorman1dir=/opt/local/share/perl5.24/man/man1 -Dvendorman3dir=/opt/local/share/perl5.24/man/man3 -Dpager=/usr/bin/less -sR -Dperlpath=/opt/local/bin/perl5.24 -Dstartperl=#!/opt/local/bin/perl5.24'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=define, usemultiplicity=define
  use64bitint=define, use64bitall=define, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='/usr/bin/clang', ccflags ='-fno-common -DPERL_DARWIN -I/opt/local/include -mmacosx-version-min=10.7 -fno-strict-aliasing -pipe -fstack-protector -I/opt/local/include -DPERL_USE_SAFE_PUTENV',
  optimize='-O3',
  cppflags='-I/opt/local/include -fno-common -DPERL_DARWIN -I/opt/local/include -mmacosx-version-min=10.7 -fno-strict-aliasing -pipe -fstack-protector -I/opt/local/include'
  ccversion='', gccversion='4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)', 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='env MACOSX_DEPLOYMENT_TARGET=10.7 /usr/bin/clang', ldflags ='-L/opt/local/lib -Wl,-headerpad_max_install_names -fstack-protector'
  libpth=/opt/local/lib /usr/local/lib /usr/bin/../lib/clang/4.2/lib /usr/lib
  libs=-lpthread -lgdbm -ldbm -ldl -lm -lutil -lc
  perllibs=-lpthread -ldl -lm -lutil -lc
  libc=, so=dylib, useshrplib=true, libperl=libperl.dylib
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
  cccdlflags=' ', lddlflags='-L/opt/local/lib -Wl,-headerpad_max_install_names -mmacosx-version-min=10.7 -bundle -undefined dynamic_lookup -fstack-protector'

Characteristics of this binary (from libperl)​:
  Compile-time options​: HAS_TIMES MULTIPLICITY PERLIO_LAYERS
  PERL_COPY_ON_WRITE PERL_DONT_CREATE_GVSV
  PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
  PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
  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
  Locally applied patches​:
  RC5
  Built under darwin
  Compiled at May 7 2016 21​:33​:18
  @​INC​:
  /opt/local/lib/perl5/site_perl/5.24/darwin-thread-multi-2level
  /opt/local/lib/perl5/site_perl/5.24
  /opt/local/lib/perl5/vendor_perl/5.24/darwin-thread-multi-2level
  /opt/local/lib/perl5/vendor_perl/5.24
  /opt/local/lib/perl5/5.24/darwin-thread-multi-2level
  /opt/local/lib/perl5/5.24
  .

@p5pRT
Copy link
Author

p5pRT commented May 17, 2016

From @tonycoz

On Sat May 07 07​:40​:21 2016, mojca@​macports.org wrote​:

Since Perl 5.22 (I only tested 5.22.1 and 5.22.2) I'm experiencing a
problem that wasn't present on 5.20.3.

dist/IO/t/cachepropagate-unix .................................
# Failed test 'datagram socket created'
# at t/cachepropagate-unix.t line 75.
Can't call method "protocol" on an undefined value at
t/cachepropagate-unix.t line 77.
# Looks like you planned 15 tests but ran 9.
# Looks like you failed 1 test of 9 run.
# Looks like your test exited with 48 just after 9.
FAILED at test 9

This happens on Mac OS X (I tested on 10.7, but is most likely present
on others as well) and with a MacPorts build.

I opened a ticket at
https://trac.macports.org/ticket/51327

See also ticket #128093.
I will try to test whether there is any difference if I change some
compiler flags or if I build Perl outside of the distribution.

This test passes successfully on both 10.10.5 and 10.11.4 with a default build of blead perl (5.24 + unrelated changes).

pallas​:t tony$ ./perl harness -v ../dist/IO/t/cachepropagate-unix.t
../dist/IO/t/cachepropagate-unix.t ..
1..15
ok 1 - stream socket created
ok 2 - protocol defined
ok 3 - domain defined
ok 4 - type defined
ok 5 - spawned a child
ok 6 - domain match
ok 7 # skip no Socket​::SO_PROTOCOL
ok 8 - type match
ok 9 - datagram socket created
ok 10 - protocol defined
ok 11 - domain defined
ok 12 - type defined
ok 13 - domain match
ok 14 # skip no Socket​::SO_PROTOCOL
ok 15 - type match
ok
All tests successful.
Files=1, Tests=15, 1 wallclock secs ( 0.01 usr 0.00 sys + 0.08 cusr 0.01 csys = 0.10 CPU)
Result​: PASS

(not using MacPorts)

5.22.2 also passes.

I don't have 10.7 to test against.

Since I can't reproduce it here, you might try adding some diagnostic code, the code that's failing is​:

  # now test datagram sockets​:
  $listener = IO​::Socket​::UNIX->new(Type => SOCK_DGRAM,
  Local => $socketpath);
  ok(defined($listener), 'datagram socket created');

you might try changing that to​:

  # now test datagram sockets​:
  $listener = IO​::Socket​::UNIX->new(Type => SOCK_DGRAM,
  Local => $socketpath)
  or diag "datagram socket​: $!";
  ok(defined($listener), 'datagram socket created');

and see if you get a useful diagnostic.

To test just the single test file​:

  ./Configure ... your flags here ...
  make test TEST_ARGS=-v TEST_FILES=../dist/IO/t/cachepropagate-unix.t

Tony

@p5pRT
Copy link
Author

p5pRT commented May 17, 2016

From mojca.miklavec.lists@gmail.com

First some unrelated stuff. I tried running with harness in the same (or at least similar way).

cd work/dir/t/
perl5.24 harness -v ../dist/IO/t/cachepropagate-unix.t

But I either get

Can't locate TAP/Harness.pm in @​INC (you may need to install the TAP​::Harness module) (@​INC contains​: ../lib) at harness line 13.
BEGIN failed--compilation aborted at harness line 13.

Or if I uncomment setting @​INC in harness, I get

Could not execute (../../t/perl -I../.. -MTestInit=U2T t/cachepropagate-unix.t)​: open3​: exec of ../../t/perl -I../.. -MTestInit=U2T t/cachepropagate-unix.t failed​: No such file or directory at /opt/local/lib/perl5/vendor_perl/5.24/TAP/Parser/Iterator/Process.pm line 165.

In the first attempt (just running "perl" or "prove") I don't get any additional debug information after making that change, but I'll try to dig further.

The problem is that the datagram socket gets created.

I tried to change the following line to

  ok(defined($listener), 'datagram socket created ' . $!);

and that one prints "Illegal seek".

ok 5 - spawned a child
not ok 6 - domain match
ok 7 # skip no Socket​::SO_PROTOCOL
not ok 8 - type match

# Failed test 'domain match'
# at cachepropagate-unix.t line 50.
# got​: undef
# expected​: '1'

# Failed test 'type match'
# at cachepropagate-unix.t line 61.
# got​: undef
# expected​: '1'
ok 9 - datagram socket created Illegal seek

@p5pRT
Copy link
Author

p5pRT commented May 17, 2016

From mojca.miklavec.lists@gmail.com

Dne Pon 16 Maj 2016 18​:34​:51 je tonyc napisal​:

To test just the single test file​:

./Configure ... your flags here ...
make test TEST_ARGS=-v TEST_FILES=../dist/IO/t/cachepropagate-unix.t

Now I'm super confused​:

$ sudo port -v build perl5.24
...
$ cd $(port work perl5.24)/perl-5.24.0
$ sudo -u macports make test TEST_ARGS=-v TEST_FILES=../dist/IO/t/cachepropagate-unix.t
...
DYLD_LIBRARY_PATH=/path/to/perl5.24/work/perl-5.24.0 ./runtests choose
t/../dist/IO/t/cachepropagate-unix ... 1..15
ok 1 - stream socket created
ok 2 - protocol defined
ok 3 - domain defined
ok 4 - type defined
ok 5 - spawned a child
ok 6 - domain match
ok 7 # skip no Socket​::SO_PROTOCOL
ok 8 - type match
ok 9 - datagram socket created Illegal seek
ok 10 - protocol defined
ok 11 - domain defined
ok 12 - type defined
ok 13 - domain match
ok 14 # skip no Socket​::SO_PROTOCOL
ok 15 - type match
ok
All tests successful.
Elapsed​: 1 sec
u=0.01 s=0.00 cu=0.10 cs=0.02 scripts=1 tests=15

Weird enough the tests succeed if I run them "isolated" from MacPorts. I started wondering if sandboxing has anything to do with the failure. I need to consult other experienced MacPorters. (Then again I wonder why this wasn't a problem back in 5.20.)

@p5pRT
Copy link
Author

p5pRT commented May 17, 2016

From mojca.miklavec.lists@gmail.com

I really need some explanation and further help here. These are two commands that are being run one after another in the same folder. "perl5.24" is the executable that was built with exactly the same flags and in exactly the same way, but it is already installed on the system. Running the test suite automatically fails; running "./perl harness ..." from the "t" subfolder succeeds (even though it results in "Illegal seek" when I print "$!"); running the installed perl5.24 or prove-5.24 fails with "Illegal seek".

$ perl-5.24.0/t> ./perl harness -v ../dist/IO/t/cachepropagate-unix.t
../dist/IO/t/cachepropagate-unix.t ..
1..15
ok 1 - stream socket created
ok 2 - protocol defined
ok 3 - domain defined
ok 4 - type defined
ok 5 - spawned a child
ok 6 - domain match
ok 7 # skip no Socket​::SO_PROTOCOL
ok 8 - type match
ok 9 - datagram socket created Illegal seek
ok 10 - protocol defined
ok 11 - domain defined
ok 12 - type defined
ok 13 - domain match
ok 14 # skip no Socket​::SO_PROTOCOL
ok 15 - type match
ok
All tests successful.
Files=1, Tests=15, 1 wallclock secs ( 0.02 usr 0.00 sys + 0.09 cusr 0.02 csys = 0.13 CPU)
Result​: PASS

$ perl-5.24.0/t> prove-5.24 -v ../dist/IO/t/cachepropagate-unix.t
../dist/IO/t/cachepropagate-unix.t ..
1..15
ok 1 - stream socket created
ok 2 - protocol defined
ok 3 - domain defined
ok 4 - type defined
ok 5 - spawned a child
not ok 6 - domain match
ok 7 # skip no Socket​::SO_PROTOCOL
not ok 8 - type match
ok 9 - datagram socket created Illegal seek
ok 10 - protocol defined
ok 11 - domain defined
ok 12 - type defined
not ok 13 - domain match
ok 14 # skip no Socket​::SO_PROTOCOL
not ok 15 - type match

# Failed test 'domain match'
# at ../dist/IO/t/cachepropagate-unix.t line 50.
# got​: undef
# expected​: '1'

# Failed test 'type match'
# at ../dist/IO/t/cachepropagate-unix.t line 61.
# got​: undef
# expected​: '1'

# Failed test 'domain match'
# at ../dist/IO/t/cachepropagate-unix.t line 86.
# got​: undef
# expected​: '1'

# Failed test 'type match'
# at ../dist/IO/t/cachepropagate-unix.t line 99.
# got​: undef
# expected​: '2'
# Looks like you failed 4 tests of 15.
Dubious, test returned 4 (wstat 1024, 0x400)
Failed 4/15 subtests
  (less 2 skipped subtests​: 9 okay)

Test Summary Report


../dist/IO/t/cachepropagate-unix.t (Wstat​: 1024 Tests​: 15 Failed​: 4)
  Failed tests​: 6, 8, 13, 15
  Non-zero exit status​: 4
Files=1, Tests=15, 1 wallclock secs ( 0.04 usr 0.01 sys + 0.13 cusr 0.02 csys = 0.20 CPU)
Result​: FAIL

@p5pRT
Copy link
Author

p5pRT commented May 17, 2016

From mojca.miklavec.lists@gmail.com

See also a slightly different problem (I can reproduce it on 10.7)​: https://trac.macports.org/ticket/51327#comment:6

@p5pRT
Copy link
Author

p5pRT commented Jun 15, 2016

From @tonycoz

On Tue May 17 04​:35​:52 2016, mojca.miklavec.lists@​gmail.com wrote​:

See also a slightly different problem (I can reproduce it on 10.7)​:
https://trac.macports.org/ticket/51327#comment:6

Your theory about the temp path could be it, that path is 99 characters long. The definition of sockaddr_un is​:

struct sockaddr_un {
  unsigned char sun_len; /* sockaddr len including null */
  sa_family_t sun_family; /* [XSI] AF_UNIX */
  char sun_path[104]; /* [XSI] path name (gag) */
};

(from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/sys/un.h)

So it seems likely you're over 103 characters, since there's also a temp directory name and "/testsock" included in the final socket path.

Socket​::pack_sockaddr_un() appears to fit what it can into sun_path and discard the rest of the path, which seems like a bug to me.

Changing pack_sockaddr_un() so it can fail would require changes to anything that calls it to handle the error.

Tony

@p5pRT
Copy link
Author

p5pRT commented Aug 10, 2016

From @tonycoz

On Tue Jun 14 23​:21​:58 2016, tonyc wrote​:

Socket​::pack_sockaddr_un() appears to fit what it can into sun_path
and discard the rest of the path, which seems like a bug to me.

Changing pack_sockaddr_un() so it can fail would require changes to
anything that calls it to handle the error.

Opened

https://rt.cpan.org/Ticket/Display.html?id=116819

Tony

@p5pRT
Copy link
Author

p5pRT commented Aug 15, 2016

From @tonycoz

On Tue Jun 14 23​:21​:58 2016, tonyc wrote​:

Changing pack_sockaddr_un() so it can fail would require changes to
anything that calls it to handle the error.

Here's a different approach, which I hope is future proof.

Tony

@p5pRT
Copy link
Author

p5pRT commented Aug 15, 2016

From @tonycoz

0001-perl-128095-check-pack_sockaddr_un-s-return-value.patch
From 4b09738d6af9f9ed8890fd7af0868339e4a3fda9 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Mon, 15 Aug 2016 10:39:22 +1000
Subject: (perl #128095) check pack_sockaddr_un()'s return value

pack_sockaddr_un() silently truncates the supplied path if it won't
fit into the sun_path member of sockaddr_un.

This may change in the future, but for now check the path in the
sockaddr matches the desired path, and skip if it doesn't.
---
 dist/IO/t/cachepropagate-unix.t | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/dist/IO/t/cachepropagate-unix.t b/dist/IO/t/cachepropagate-unix.t
index e3e438e..20c70dd 100644
--- a/dist/IO/t/cachepropagate-unix.t
+++ b/dist/IO/t/cachepropagate-unix.t
@@ -14,10 +14,21 @@ use Test::More;
 plan skip_all => "UNIX domain sockets not implemented on $^O"
   if ($^O =~ m/^(?:qnx|nto|vos|MSWin32|VMS)$/);
 
-plan tests => 15;
-
 my $socketpath = catfile(tempdir( CLEANUP => 1 ), 'testsock');
 
+# check the socketpath fits in sun_path.
+#
+# pack_sockaddr_un() just truncates the path, this may change, but how
+# it will handle such a condition is undetermined (and we might need
+# to work with older versions of Socket outside of a perl build)
+# https://rt.cpan.org/Ticket/Display.html?id=116819
+
+my $name = eval { pack_sockaddr_un($socketpath) };
+defined $name && (unpack_sockaddr_un($name))[0] eq $socketpath
+  or plan skip_all => "socketpath too long for sockaddr_un";
+
+plan tests => 15;
+
 # start testing stream sockets:
 my $listener = IO::Socket::UNIX->new(Type => SOCK_STREAM,
 				     Listen => 1,
-- 
2.1.4

@p5pRT
Copy link
Author

p5pRT commented Aug 18, 2016

From mojca@macports.org

On 15 August 2016 at 02​:41, Tony Cook via RT wrote​:

On Tue Jun 14 23​:21​:58 2016, tonyc wrote​:

Changing pack_sockaddr_un() so it can fail would require changes to
anything that calls it to handle the error.

Here's a different approach, which I hope is future proof.

Thank you. I cannot judge about the contents of the patch, but I can
confirm that the tests pass now.

Mojca

@p5pRT
Copy link
Author

p5pRT commented Sep 6, 2016

From @tonycoz

On Wed Aug 17 18​:31​:57 2016, mojca@​macports.org wrote​:

On 15 August 2016 at 02​:41, Tony Cook via RT wrote​:

On Tue Jun 14 23​:21​:58 2016, tonyc wrote​:

Changing pack_sockaddr_un() so it can fail would require changes to
anything that calls it to handle the error.

Here's a different approach, which I hope is future proof.

Thank you. I cannot judge about the contents of the patch, but I can
confirm that the tests pass now.

Thanks, applied to blead as 5b549d1.

Tony

@p5pRT
Copy link
Author

p5pRT commented Sep 6, 2016

@tonycoz - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

p5pRT commented May 30, 2017

From @khwilliamson

Thank you for filing this report. You have helped make Perl better.

With the release today of Perl 5.26.0, this and 210 other issues have been
resolved.

Perl 5.26.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.26.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT p5pRT closed this as completed May 30, 2017
@p5pRT
Copy link
Author

p5pRT commented May 30, 2017

@khwilliamson - Status changed from 'pending release' to 'resolved'

@p5pRT
Copy link
Author

p5pRT commented Jun 1, 2017

From mojca@macports.org

What about backporting the patch to 5.24?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant