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

IO::Socket fails to propagate socket type information to accept()ed children #12079

Closed
p5pRT opened this issue May 2, 2012 · 29 comments
Closed

Comments

@p5pRT
Copy link

p5pRT commented May 2, 2012

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

Searchable as RT112736$

@p5pRT
Copy link
Author

p5pRT commented May 2, 2012

From @jmdh

Dear all,

I am filing this as a new rt.perl.org ticket, but it relates to extensive
discussions and patches which have been supplied at
<https://rt.cpan.org/Ticket/Display.html?id=61577>. I'm making a new
ticket since there have been some concerns that rt.cpan.org wasn't the
correct location for reports about this bug in IO​::Socket (since it is
apparently core-maintained).

This is also tracked at
<http​://bugs.debian.org/cgi-bin/bugreport.cgi?bug=659075>.

I won't attempt to summarise the whole of both threads, but the current
situation is that there appears to be a patch and a series of
three test cases which demonstrate that the patch fixes the bug
on at least GNU/Linux, and does not make the situation any worse on some
other platforms (including FreeBSD and Darwin).

There appears to be strong reasons to apply this patch in Debian perl,
but I'd like to get, if possible, some more feedback from porters
about this, because we would rather not carry a patch for this
indefinitely. The timing is quite awkward, because 5.16 is already
frozen, and Debian is going to be frozen (with our version of 5.14)
in a month or so.

The current proposed patch is

http​://perl5.git.perl.org/perl.git/commit/25153b9f6968c445f8551f2c0aae1c46580b7767

The smoke reports indicate that the tests currently fail on anything
which isn't Linux, but my understanding is that this wouldn't be a
regression on those platforms.

http​://perl.develop-help.com/?b=smoke-me%2Fcpan61577-dom

I would be very grateful for any fresh feedback on this issue.

Thanks,
Dominic.

--
Dominic Hargreaves | http​://www.larted.org.uk/~dom/
PGP key 5178E2A5 from the.earth.li (keyserver,web,email)

@p5pRT
Copy link
Author

p5pRT commented May 4, 2012

From @tonycoz

On Wed, May 02, 2012 at 03​:31​:39PM -0700, Dominic Hargreaves wrote​:

The smoke reports indicate that the tests currently fail on anything
which isn't Linux, but my understanding is that this wouldn't be a
regression on those platforms.

http​://perl.develop-help.com/?b=smoke-me%2Fcpan61577-dom

I would be very grateful for any fresh feedback on this issue.

At the very least it will need TODO or SKIP on the unsupported
platforms.

Tony

@p5pRT
Copy link
Author

p5pRT commented May 4, 2012

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

@p5pRT
Copy link
Author

p5pRT commented May 8, 2012

From @nwc10

On Fri, May 04, 2012 at 02​:15​:56PM +1000, Tony Cook wrote​:

On Wed, May 02, 2012 at 03​:31​:39PM -0700, Dominic Hargreaves wrote​:

  > The current proposed patch is
  >
  > http​://perl5.git.perl.org/perl.git/commit/25153b9f6968c445f8551f2c0aae1c46580b7767

The smoke reports indicate that the tests currently fail on anything
which isn't Linux, but my understanding is that this wouldn't be a
regression on those platforms.

http​://perl.develop-help.com/?b=smoke-me%2Fcpan61577-dom

I would be very grateful for any fresh feedback on this issue.

At the very least it will need TODO or SKIP on the unsupported
platforms.

Sounds like it might be easier to TODO or SKIP on anything other than
platforms where it's known to work.

Rather minor, but I noticed that the new tests were written using Test.
Could that be changed to Test​::More? I really don't think that we should be
"promoting" Test in the core these days, for several reasons, including the
fact that it doesn't give anywhere near as good diagnostics when tests fail.

Nicholas Clark

@p5pRT
Copy link
Author

p5pRT commented May 9, 2012

From dkg@fifthhorseman.net

Attached is an amended patch against blead. Its main changes compared
to smoke-me/61577-dom are​:

* uses Test​::More instead of Test (thanks to Nicholas Clark for the
suggestion)

* SKIPs the relevant tests on platforms where Socket​::SO_TYPE or
Socket​::SO_PROTOCOL are not defined

* uses File​::Temp and File​::Spec to construct the path for the
UNIX-domain socket in a platform-independent and $TMPDIR-respecting fashion

* SKIPs all IO​::Socket​::UNIX tests on platforms known to not support
UNIX-domain sockets

If there are other changes that need to be made for this to be
considered, please let me know.

@p5pRT
Copy link
Author

p5pRT commented May 9, 2012

From dkg@fifthhorseman.net

robustly-refresh-missing-cached-socket-details-v5.patch
commit 5f4a26e9a109d48b971e34df87529cc1e10260f9
Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Date:   Fri Feb 17 14:29:14 2012 -0800

    [rt.cpan.org #61577] sockdomain and socktype undef on newly accepted sockets
    
    There appears to be a flaw in IO::Socket where some IO::Socket objects
    are unable to properly report their socktype, sockdomain, or protocol
    (they return undef, even when the underlying socket is sufficiently
    initialized to have these properties).
    
    The attached patch should cover IO::Socket objects created via accept(),
    new_from_fd(), new(), and anywhere else whose details haven't been
    properly cached.
    
    No new code should be executed on IO::Socket objects whose details are
    already cached and present.

diff --git a/AUTHORS b/AUTHORS
index 88342aa..1547be2 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -250,6 +250,7 @@ Daniel Chetlin			<daniel@chetlin.com>
 Daniel Dragan			<bulk88@hotmail.com>
 Daniel Frederick Crisman	<daniel@crisman.org>
 Daniel Grisinger		<dgris@dimensional.com>
+Daniel Kahn Gillmor		<dkg@fifthhorseman.net>
 Daniel Lieberman		<daniel@bitpusher.com>
 Daniel Muiño			<dmuino@afip.gov.ar>
 Daniel P. Berrange		<dan@berrange.com>
diff --git a/MANIFEST b/MANIFEST
index 2be6ea7..1f5219d 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -3259,6 +3259,9 @@ dist/IO/Makefile.PL		IO extension makefile writer
 dist/IO/poll.c			IO poll() emulation using select()
 dist/IO/poll.h			IO poll() emulation using select()
 dist/IO/README			IO extension maintenance notice
+dist/IO/t/cachepropagate-tcp.t	See if IO::Socket duplication works
+dist/IO/t/cachepropagate-udp.t	See if IO::Socket duplication works
+dist/IO/t/cachepropagate-unix.t	See if IO::Socket duplication works
 dist/IO/t/io_const.t		See if constants from IO work
 dist/IO/t/io_dir.t		See if directory-related methods from IO work
 dist/IO/t/io_dup.t		See if dup()-related methods from IO work
diff --git a/META.yml b/META.yml
index 9271e61..faa01d5 100644
--- a/META.yml
+++ b/META.yml
@@ -78,6 +78,9 @@ no_index:
     - dist/IO/poll.c
     - dist/IO/poll.h
     - dist/IO/README
+    - dist/IO/t/cachepropagate-tcp.t
+    - dist/IO/t/cachepropagate-udp.t
+    - dist/IO/t/cachepropagate-unix.t
     - dist/IO/t/IO.t
     - dist/IO/t/io_const.t
     - dist/IO/t/io_dir.t
diff --git a/dist/IO/lib/IO/Socket.pm b/dist/IO/lib/IO/Socket.pm
index 529423b..393f836 100644
--- a/dist/IO/lib/IO/Socket.pm
+++ b/dist/IO/lib/IO/Socket.pm
@@ -24,7 +24,7 @@ require IO::Socket::UNIX if ($^O ne 'epoc' && $^O ne 'symbian');
 
 @ISA = qw(IO::Handle);
 
-$VERSION = "1.34";
+$VERSION = "1.35";
 
 @EXPORT_OK = qw(sockatmark);
 
@@ -349,18 +349,27 @@ sub timeout {
 sub sockdomain {
     @_ == 1 or croak 'usage: $sock->sockdomain()';
     my $sock = shift;
+    if (!defined(${*$sock}{'io_socket_domain'})) {
+	my $addr = $sock->sockname();
+	${*$sock}{'io_socket_domain'} = sockaddr_family($addr)
+	   if (defined($addr));
+    }
     ${*$sock}{'io_socket_domain'};
 }
 
 sub socktype {
     @_ == 1 or croak 'usage: $sock->socktype()';
     my $sock = shift;
+    ${*$sock}{'io_socket_type'} = $sock->sockopt(Socket::SO_TYPE)
+	if (!defined(${*$sock}{'io_socket_type'}) && defined(eval{Socket::SO_TYPE}));
     ${*$sock}{'io_socket_type'}
 }
 
 sub protocol {
     @_ == 1 or croak 'usage: $sock->protocol()';
     my($sock) = @_;
+    ${*$sock}{'io_socket_proto'} = $sock->sockopt(Socket::SO_PROTOCOL)
+	if (!defined(${*$sock}{'io_socket_proto'}) && defined(eval{Socket::SO_PROTOCOL}));
     ${*$sock}{'io_socket_proto'};
 }
 
diff --git a/dist/IO/t/cachepropagate-tcp.t b/dist/IO/t/cachepropagate-tcp.t
new file mode 100644
index 0000000..9c26b45
--- /dev/null
+++ b/dist/IO/t/cachepropagate-tcp.t
@@ -0,0 +1,51 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use IO::Socket;
+use IO::Socket::INET;
+use Socket;
+use Test::More;
+
+plan tests => 8;
+
+my $listener = IO::Socket::INET->new(Listen => 1,
+                                     LocalAddr => '127.0.0.1',
+                                     Proto => 'tcp');
+ok(defined($listener), 'socket created');
+
+my $port = $listener->sockport();
+
+my $p = $listener->protocol();
+ok(defined($p), 'protocol defined');
+my $d = $listener->sockdomain();
+ok(defined($d), 'domain defined');
+my $s = $listener->socktype();
+ok(defined($s), 'type defined');
+
+my $cpid = fork();
+if (0 == $cpid) {
+  # the child:
+  sleep(1);
+  my $connector = IO::Socket::INET->new(PeerAddr => '127.0.0.1',
+                                        PeerPort => $port,
+                                        Proto => 'tcp');
+  exit(0);
+} else {;
+  ok(defined($cpid), 'spawned a child');
+}
+
+my $new = $listener->accept();
+
+is($new->sockdomain(), $d, 'domain match');
+SKIP: {
+    skip "no Socket::SO_PROTOCOL", 1 if !defined(eval { Socket::SO_PROTOCOL });
+    is($new->protocol(), $p, 'protocol match');
+}
+SKIP: {
+    skip "no Socket::SO_TYPE", 1 if !defined(eval { Socket::SO_TYPE });
+    is($new->socktype(), $s, 'type match');
+}
+
+wait();
diff --git a/dist/IO/t/cachepropagate-udp.t b/dist/IO/t/cachepropagate-udp.t
new file mode 100644
index 0000000..91cff37
--- /dev/null
+++ b/dist/IO/t/cachepropagate-udp.t
@@ -0,0 +1,34 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use IO::Socket;
+use IO::Socket::INET;
+use Socket;
+use Test::More;
+
+plan tests => 7;
+
+my $listener = IO::Socket::INET->new(LocalAddr => '127.0.0.1',
+                                     Proto => 'udp');
+ok(defined($listener), 'socket created');
+
+my $p = $listener->protocol();
+ok(defined($p), 'protocol defined');
+my $d = $listener->sockdomain();
+ok(defined($d), 'domain defined');
+my $s = $listener->socktype();
+ok(defined($s), 'type defined');
+
+my $new = IO::Socket::INET->new_from_fd($listener->fileno(), 'r+');
+
+is($new->sockdomain(), $d, 'domain match');
+SKIP: {
+    skip "no Socket::SO_PROTOCOL", 1 if !defined(eval { Socket::SO_PROTOCOL });
+    is($new->protocol(), $p, 'protocol match');
+}
+SKIP: {
+    skip "no Socket::SO_TYPE", 1 if !defined(eval { Socket::SO_TYPE });
+    is($new->socktype(), $s, 'type match');
+}
diff --git a/dist/IO/t/cachepropagate-unix.t b/dist/IO/t/cachepropagate-unix.t
new file mode 100644
index 0000000..375f28a
--- /dev/null
+++ b/dist/IO/t/cachepropagate-unix.t
@@ -0,0 +1,83 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use File::Temp qw(tempdir);
+use File::Spec::Functions;
+use IO::Socket;
+use IO::Socket::UNIX;
+use Socket;
+use Test::More;
+
+plan tests => 15;
+
+SKIP: {
+    skip "UNIX domain sockets not implemented on $^O", 15 if ($^O =~ m/^(?:qnx|nto|vos|MSWin32)$/);
+
+    my $socketpath = catfile(tempdir( CLEANUP => 1 ), 'testsock');
+
+    # start testing stream sockets:
+
+    my $listener = IO::Socket::UNIX->new(Type => SOCK_STREAM,
+					 Listen => 1,
+					 Local => $socketpath);
+    ok(defined($listener), 'stream socket created');
+
+    my $p = $listener->protocol();
+    ok(defined($p), 'protocol defined');
+    my $d = $listener->sockdomain();
+    ok(defined($d), 'domain defined');
+    my $s = $listener->socktype();
+    ok(defined($s), 'type defined');
+
+    my $cpid = fork();
+    if (0 == $cpid) {
+      # the child:
+      sleep(1);
+      my $connector = IO::Socket::UNIX->new(Peer => $socketpath);
+      exit(0);
+    } else {
+      ok(defined($cpid), 'spawned a child');
+    }
+
+    my $new = $listener->accept();
+
+    is($new->sockdomain(), $d, 'domain match');
+  SKIP: {
+      skip "no Socket::SO_PROTOCOL", 1 if !defined(eval { Socket::SO_PROTOCOL });
+      is($new->protocol(), $p, 'protocol match');
+    }
+  SKIP: {
+      skip "no Socket::SO_TYPE", 1 if !defined(eval { Socket::SO_TYPE });
+      is($new->socktype(), $s, 'type match');
+    }
+
+    unlink($socketpath);
+    wait();
+
+    # now test datagram sockets:
+    $listener = IO::Socket::UNIX->new(Type => SOCK_DGRAM,
+				      Local => $socketpath);
+    ok(defined($listener), 'datagram socket created');
+
+    $p = $listener->protocol();
+    ok(defined($p), 'protocol defined');
+    $d = $listener->sockdomain();
+    ok(defined($d), 'domain defined');
+    $s = $listener->socktype();
+    ok(defined($s), 'type defined');
+
+    $new = IO::Socket::UNIX->new_from_fd($listener->fileno(), 'r+');
+
+    is($new->sockdomain(), $d, 'domain match');
+  SKIP: {
+      skip "no Socket::SO_PROTOCOL", 1 if !defined(eval { Socket::SO_PROTOCOL });
+      is($new->protocol(), $p, 'protocol match');
+    }
+  SKIP: {
+      skip "no Socket::SO_TYPE", 1 if !defined(eval { Socket::SO_TYPE });
+      is($new->socktype(), $s, 'type match');
+    }
+    unlink($socketpath);
+  }

@p5pRT
Copy link
Author

p5pRT commented May 9, 2012

From @rjbs

This needs to get done ASAP if it's going to go in. I'd like to get RC0 cut
this week if at all possible.

--
rjbs

@p5pRT
Copy link
Author

p5pRT commented May 9, 2012

From @tonycoz

On Tue, May 08, 2012 at 10​:34​:05AM +0100, Nicholas Clark wrote​:

Sounds like it might be easier to TODO or SKIP on anything other than
platforms where it's known to work.

Rather minor, but I noticed that the new tests were written using Test.
Could that be changed to Test​::More? I really don't think that we should be
"promoting" Test in the core these days, for several reasons, including the
fact that it doesn't give anywhere near as good diagnostics when tests fail.

The existing tests use a mix of C< print "ok 1\n" >, Test and test.pl.

Either a dependency on perl 5.006002 or on Test​::More would need to be
added for a CPAN release.

Tony

@p5pRT
Copy link
Author

p5pRT commented May 9, 2012

From @jmdh

On Tue, May 08, 2012 at 10​:09​:12PM -0700, Tony Cook via RT wrote​:

On Tue, May 08, 2012 at 10​:34​:05AM +0100, Nicholas Clark wrote​:

Sounds like it might be easier to TODO or SKIP on anything other than
platforms where it's known to work.

Rather minor, but I noticed that the new tests were written using Test.
Could that be changed to Test​::More? I really don't think that we should be
"promoting" Test in the core these days, for several reasons, including the
fact that it doesn't give anywhere near as good diagnostics when tests fail.

The existing tests use a mix of C< print "ok 1\n" >, Test and test.pl.

Either a dependency on perl 5.006002 or on Test​::More would need to be
added for a CPAN release.

Daniel's updated patch (v5) does not seem to contain a mix, unless my
eyes are deceiving me. Thanks for the note about the Test​::More
dependency.

--
Dominic Hargreaves | http​://www.larted.org.uk/~dom/
PGP key 5178E2A5 from the.earth.li (keyserver,web,email)

@p5pRT
Copy link
Author

p5pRT commented May 9, 2012

From @jmdh

On Tue, May 08, 2012 at 08​:09​:43PM -0700, Ricardo Signes via RT wrote​:

This needs to get done ASAP if it's going to go in. I'd like to get RC0 cut
this week if at all possible.

As I see it the next thing is to smoke the updated patch from
Daniel; and would any more experienced committers be able to review the
overall ticket for sanity at the same time?

I probably won't be able to get this smoking today, and possibly not
tomorrow either - maybe a smoke-me commit isn't needed, however.

--
Dominic Hargreaves | http​://www.larted.org.uk/~dom/
PGP key 5178E2A5 from the.earth.li (keyserver,web,email)

@p5pRT
Copy link
Author

p5pRT commented May 9, 2012

From @jmdh

On Tue, May 08, 2012 at 08​:09​:43PM -0700, Ricardo Signes via RT wrote​:

This needs to get done ASAP if it's going to go in. I'd like to get RC0 cut
this week if at all possible.

As discussed, an updated set of changes is now in smoke-me/cpan61577-dom.
This also includes the changes from Tony (tonyc/cpan61577) to skip the
forking tests if fork is not available.

--
Dominic Hargreaves | http​://www.larted.org.uk/~dom/
PGP key 5178E2A5 from the.earth.li (keyserver,web,email)

@p5pRT
Copy link
Author

p5pRT commented May 10, 2012

From @cpansprout

On Wed May 09 11​:50​:33 2012, dom wrote​:

On Tue, May 08, 2012 at 08​:09​:43PM -0700, Ricardo Signes via RT wrote​:

This needs to get done ASAP if it's going to go in. I'd like to get
RC0 cut
this week if at all possible.

As discussed, an updated set of changes is now in smoke-me/cpan61577-
dom.
This also includes the changes from Tony (tonyc/cpan61577) to skip the
forking tests if fork is not available.

rjbs has applied this to blead as commits 271d04e, b690361 and
01b71c8.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented May 10, 2012

@cpansprout - Status changed from 'open' to 'resolved'

@p5pRT
Copy link
Author

p5pRT commented May 14, 2012

From @jmdh

On Thu, May 10, 2012 at 12​:44​:25PM -0700, Father Chrysostomos via RT wrote​:

On Wed May 09 11​:50​:33 2012, dom wrote​:

On Tue, May 08, 2012 at 08​:09​:43PM -0700, Ricardo Signes via RT wrote​:

This needs to get done ASAP if it's going to go in. I'd like to get
RC0 cut
this week if at all possible.

As discussed, an updated set of changes is now in smoke-me/cpan61577-
dom.
This also includes the changes from Tony (tonyc/cpan61577) to skip the
forking tests if fork is not available.

rjbs has applied this to blead as commits 271d04e, b690361 and
01b71c8.

There are still some new test failures on some platforms relating to
this. The general consensus on IRC was that it would probably be better
to tackle these post-5.16 rather than rushing during the RC process by
reverting the changes.

The tests are currently known to be failing on HP-UX and AIX​:

http​://perl5.test-smoke.org/report/471
http​://perl5.test-smoke.org/report/470
http​://perl5.test-smoke.org/report/469
http​://pasta.test-smoke.org/249

Dominic.

--
Dominic Hargreaves | http​://www.larted.org.uk/~dom/
PGP key 5178E2A5 from the.earth.li (keyserver,web,email)

@p5pRT
Copy link
Author

p5pRT commented May 14, 2012

@jmdh - Status changed from 'resolved' to 'open'

@p5pRT
Copy link
Author

p5pRT commented May 14, 2012

From @jmdh

On Mon, May 14, 2012 at 07​:04​:51PM +0100, Dominic Hargreaves wrote​:

There are still some new test failures on some platforms relating to
this. The general consensus on IRC was that it would probably be better
to tackle these post-5.16 rather than rushing during the RC process by
reverting the changes.

The tests are currently known to be failing on HP-UX and AIX​:

http​://perl5.test-smoke.org/report/471
http​://perl5.test-smoke.org/report/470
http​://perl5.test-smoke.org/report/469
http​://pasta.test-smoke.org/249

Now reverted in the release-5.16 branch by commit
a5bed83.

TonyC also wondered whether this bug could be redefined as​:

'$sock->protocol is unreliable and should be documented that way'.

--
Dominic Hargreaves | http​://www.larted.org.uk/~dom/
PGP key 5178E2A5 from the.earth.li (keyserver,web,email)

@p5pRT
Copy link
Author

p5pRT commented May 15, 2012

From @tonycoz

On Mon, May 14, 2012 at 08​:58​:07PM +0100, Dominic Hargreaves wrote​:

On Mon, May 14, 2012 at 07​:04​:51PM +0100, Dominic Hargreaves wrote​:

There are still some new test failures on some platforms relating to
this. The general consensus on IRC was that it would probably be better
to tackle these post-5.16 rather than rushing during the RC process by
reverting the changes.

The tests are currently known to be failing on HP-UX and AIX​:

http​://perl5.test-smoke.org/report/471
http​://perl5.test-smoke.org/report/470
http​://perl5.test-smoke.org/report/469
http​://pasta.test-smoke.org/249

Now reverted in the release-5.16 branch by commit
a5bed83.

TonyC also wondered whether this bug could be redefined as​:

'$sock->protocol is unreliable and should be documented that way'.

I suspect more cases could be handled by copying the relevant
information from the listener socket in accept().

That might be a performance regression though.

Tony

@p5pRT
Copy link
Author

p5pRT commented May 15, 2012

From dkg@fifthhorseman.net

On 05/14/2012 08​:35 PM, Tony Cook via RT wrote​:

On Mon, May 14, 2012 at 08​:58​:07PM +0100, Dominic Hargreaves wrote​:

Now reverted in the release-5.16 branch by commit
a5bed83.

If i'm understanding correctly, this reversion seems like a shame to me.
Removing the fixes and the tests leaves perl 5.16 just as broken on the
unsupported platforms, and *more* broken on the platforms that are
capable of taking advantage of the fix.

TonyC also wondered whether this bug could be redefined as​:

'$sock->protocol is unreliable and should be documented that way'.

It's a little late for that -- i believe these socket metadata functions
(not just ->protocol) are already relied on by CPAN modules in
circumstances that can't guarantee they'll be populated by an explicit
new() invocation.

I suspect more cases could be handled by copying the relevant
information from the listener socket in accept().

That might be a performance regression though.

As discussed in the CPAN ticket, That approach also doesn't cover
new_from_fd() or any other future mechanism that might involve the
creation of a new IO​::Socket object without an explicit new() call.

Regards,

  --dkg

@p5pRT
Copy link
Author

p5pRT commented May 15, 2012

From dkg@fifthhorseman.net

On 05/14/2012 02​:05 PM, Dominic Hargreaves via RT wrote​:

There are still some new test failures on some platforms relating to
this. The general consensus on IRC was that it would probably be better
to tackle these post-5.16 rather than rushing during the RC process by
reverting the changes.

i'm not sure whether this means that the proposed fixes to IO/Socket.pm
will be in 5.16, or will not be in 5.16. I'm hoping for the former,
since without the changes, these tests currently fail on *all*
architectures. Not including the tests won't make the existing
IO​::Socket any less buggy.

The tests are currently known to be failing on HP-UX and AIX​:

http​://perl5.test-smoke.org/report/471

AIX​: cachepropagate-unix.t non-zero exit status 29 -- it's not clear to
me what this means, and i don't see any more data in the logs to dig deeper.

http​://perl5.test-smoke.org/report/470

HP-UX​: "domain match" test fails, which means that sockdomain on an
accepted unix-domain socket returns undef. Does sockaddr_family() not
work on sockets returned from accept() on this platform?

http​://perl5.test-smoke.org/report/469
http​://pasta.test-smoke.org/249

These two are both HP-UX failing in the same way as 470, above, fwict.

I have neither HP-UX nor AIX platforms to test these myself.

  --dkg

@p5pRT
Copy link
Author

p5pRT commented May 15, 2012

From @Leont

On Tue, May 15, 2012 at 6​:46 AM, Daniel Kahn Gillmor
<dkg@​fifthhorseman.net> wrote​:

If i'm understanding correctly, this reversion seems like a shame to me.
 Removing the fixes and the tests leaves perl 5.16 just as broken on the
unsupported platforms, and *more* broken on the platforms that are
capable of taking advantage of the fix.

IO is dual-lifed, you can easily upgrade it to the fixed version as
soon as it's made available. It would have been nice if that fix what
available on time for inclusion into 5.16, but it's not like this is a
critical issue.

Leon

@p5pRT
Copy link
Author

p5pRT commented May 18, 2012

From dkg@fifthhorseman.net

On Tue May 15 04​:48​:52 2012, dkg wrote​:

HP-UX​: "domain match" test fails, which means that sockdomain on an
accepted unix-domain socket returns undef. Does sockaddr_family() not
work on sockets returned from accept() on this platform?

I was graciously offered access to an HP-UX B.11.23 machine for testing.
I can confirm that on HP-UX, the behavior of getsockname is different
than on debian GNU/Linux if it is triggered after trying to read from
the socket​:

0 dkg@​debian​:~$ perl ./test_sockaddr_family.pl
initial family​: 1
got '' from family 1
0 dkg@​debian​:~$

0 dkg@​hpux​:~$ perl ./test_sockaddr_family.pl
initial family​: 1
getsockname returned undef on accept()ed socket after reading
0 dkg@​hpux​:~$

This appears to be the case with perl 5.8.8 (native to this version of
HP-UX) as well as perl 5.14.

I'm still unclear on why this caused problems with the cachepropagate
tests, though. Perhaps this is happening to IO​::Socket objects because
they are doing some buffered pre-reads or something?

I was unable replicate this behavior in C, however. possibly because i
was using system-level read() instead of fread()? I've attached my C
test harness in case someone else wants to take a crack at it from where
i've left off.

@p5pRT
Copy link
Author

p5pRT commented May 18, 2012

@p5pRT
Copy link
Author

p5pRT commented May 18, 2012

From dkg@fifthhorseman.net

#define _XOPEN_SOURCE_EXTENDED

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <string.h>
#include <sys/wait.h>
#include <stdio.h>
#include <errno.h>

#define SOCKPATH "./socket"

void report_family(int sock, const char * state) {
  int family = 0;
  socklen_t retlen;
  struct sockaddr_un c;
  retlen = sizeof(c);
  if (0 != getsockname(sock, (struct sockaddr*)(&c), &retlen)) {
    printf("failed to getsockname on socket %s: [%d] (%s)\n", state, errno, strerror(errno));
  } else {
    family = ((struct sockaddr*)(&c))->sa_family;
    printf("getsockname shows family %d (%s)\n", family, state);
  }
}

int main() {
  int sock, accepted;
  struct sockaddr_un a, b, c;
  socklen_t retlen;
  pid_t child_pid;
  char buf[4];
  int status;
  int family = 0;

  memset(buf, 0, sizeof(buf));
  unlink(SOCKPATH);

  sock = socket(AF_UNIX, SOCK_STREAM, 0);
  a.sun_family = AF_UNIX;
  strcpy(a.sun_path, SOCKPATH);
  bind(sock, (struct sockaddr*)(&a), sizeof(a));
  report_family(sock, "listener, early");

  child_pid = fork();
  if (child_pid) {
    listen(sock, 2);
    retlen = sizeof(b);
    accepted = accept(sock, (struct sockaddr*)(&b), &retlen);
    report_family(accepted, "accepted, post-accept");
    close(sock);
    report_family(accepted, "accepted, after-parent-closed");
    read(accepted, buf, sizeof(buf));
    report_family(accepted, "accepted, after-read");
    printf("got '%s'\n", buf);
    close(accepted);
    waitpid(child_pid, &status, 0);
    unlink(SOCKPATH);
  } else {
    close(sock);
    sock = socket(AF_UNIX, SOCK_STREAM, 0);
    sleep(1);
    connect(sock, (struct sockaddr*)(&a), sizeof(a));
    write(sock, "fo", 2);
    /*
    sleep(1);
    */
    close(sock);
  }
  return 0;
}

@p5pRT
Copy link
Author

p5pRT commented Jul 5, 2012

From @cpansprout

Was this resolved by these commits?

93a5d7b
76d04ca
dafec47
1804235

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Jul 6, 2012

From @tonycoz

On Thu, Jul 05, 2012 at 02​:15​:02PM -0700, Father Chrysostomos via RT wrote​:

Was this resolved by these commits?

93a5d7b
76d04ca
dafec47
1804235

I hope so, but I need to follow up on why some tests that were failing
intermittently on HP-UX are now succeeding.

Tony

@p5pRT
Copy link
Author

p5pRT commented Jul 6, 2012

From @jmdh

On Thu, Jul 05, 2012 at 05​:13​:21PM -0700, Tony Cook via RT wrote​:

On Thu, Jul 05, 2012 at 02​:15​:02PM -0700, Father Chrysostomos via RT wrote​:

Was this resolved by these commits?

93a5d7b
76d04ca
dafec47
1804235

I hope so, but I need to follow up on why some tests that were failing
intermittently on HP-UX are now succeeding.

Thanks very much for following up on this so far Tony - it's good
to see this in blead at last.

Cheers,
Dominic.

--
Dominic Hargreaves | http​://www.larted.org.uk/~dom/
PGP key 5178E2A5 from the.earth.li (keyserver,web,email)

@p5pRT
Copy link
Author

p5pRT commented Sep 20, 2012

From @cpansprout

On Thu Jul 05 17​:13​:21 2012, tonyc wrote​:

On Thu, Jul 05, 2012 at 02​:15​:02PM -0700, Father Chrysostomos via RT
wrote​:

Was this resolved by these commits?

93a5d7b
76d04ca
dafec47
1804235

I hope so, but I need to follow up on why some tests that were failing
intermittently on HP-UX are now succeeding.

Have you had a chance to do that?

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Oct 5, 2012

From @tonycoz

On Wed Sep 19 22​:12​:56 2012, sprout wrote​:

On Thu Jul 05 17​:13​:21 2012, tonyc wrote​:

On Thu, Jul 05, 2012 at 02​:15​:02PM -0700, Father Chrysostomos via RT
wrote​:

Was this resolved by these commits?

93a5d7b
76d04ca
dafec47
1804235

I hope so, but I need to follow up on why some tests that were failing
intermittently on HP-UX are now succeeding.

Have you had a chance to do that?

I can't reproduce the failure on HP-UX with the older commit, so I'm
closing this ticket.

Tony

@p5pRT
Copy link
Author

p5pRT commented Oct 5, 2012

@tonycoz - Status changed from 'open' to 'resolved'

@p5pRT p5pRT closed this as completed Oct 5, 2012
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