NetBSD Problem Report #55690

From www@netbsd.org  Thu Oct  1 05:20:58 2020
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 66B081A9217
	for <gnats-bugs@gnats.NetBSD.org>; Thu,  1 Oct 2020 05:20:58 +0000 (UTC)
Message-Id: <20201001052057.47BF61A923A@mollari.NetBSD.org>
Date: Thu,  1 Oct 2020 05:20:57 +0000 (UTC)
From: rokuyama.rk@gmail.com
Reply-To: rokuyama.rk@gmail.com
To: gnats-bugs@NetBSD.org
Subject: GCC9 -pipe not working with PIPE_SOCKETPAIR
X-Send-Pr-Version: www-1.0

>Number:         55690
>Category:       kern
>Synopsis:       GCC9 -pipe not working with PIPE_SOCKETPAIR
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    jdolecek
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 01 05:25:00 +0000 2020
>Closed-Date:    Sun Feb 11 13:04:05 +0000 2024
>Last-Modified:  Sun Feb 11 13:05:01 +0000 2024
>Originator:     Rin Okuyama
>Release:        9.99.73
>Organization:
Department of Physics, Meiji University
>Environment:
aarch64:
NetBSD rpi 9.99.73 NetBSD 9.99.73 (PIPE) #0: Thu Oct  1 13:23:40 JST 2020  rin@latipes:/usr/src/sys/arch/evbarm/compile/PIPE evbarm

m68k:
NetBSD sun3 9.99.73 NetBSD 9.99.73 (GENERIC) #4: Tue Sep 29 00:02:57 JST 2020  rin@latipes:/sys/arch/sun3/compile/GENERIC sun3

powerpc/ibm4xx:
NetBSD obs266 9.99.73 NetBSD 9.99.73 (OBS266_PIPE) #0: Tue Sep 29 00:20:09 JST 2020  rin@latipes:/sys/arch/evbppc/compile/OBS266_PIPE evbppc
>Description:
For various archs (at least for aarch64, m68k, and powerpc/ibm4xx),
-pipe option for GCC9 does not work well on kernel with PIPE_SOCKETPAIR
option enabled. This problem occurs regardless whether kernel, libc and
etc. are built by GCC9 or GCC8.

For example, ``make package'' for lang/perl5, which adds -pipe option to
CFLAGS by default, stalls somewhere, different from ports to ports, but
completely reproducible places. Here, cc1 and cc sleeps eternally at
netio in write(2) and read(2). Kernel itself is alive, and cc1 and cc
can be terminated by ^C.

Also, some tests related to pipe(2), fails on PIPE_SOCKETPAIR kernel:

- lib/libc/sys/t_pipe2

    pipe2_cloexec: [0.011948s] Failed: /usr/src/tests/lib/libc/sys/t_pipe2.c:65: (fcntl(fd[0], F_GETFD) & FD_CLOEXEC) != 0 not met

- kernel/kqueue/write/t_pipe:pipe1

    pipe1: [0.022409s] Failed: /usr/src/tests/kernel/kqueue/write/t_pipe.c:67: (n = kevent(kq, event, 1, NULL, 0, NULL)) != -1: got: 0
>How-To-Repeat:
Try to build lang/perl5 on kernel with PIPE_SOCKETPAIR option enabled.
>Fix:
As a workaround, disabling PIPE_SOCKETPAIR option resolves the problem.
Also, there were no such problem for GCC8 -pipe as far as I can see.

>Release-Note:

>Audit-Trail:

From: Rin Okuyama <rokuyama.rk@gmail.com>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@NetBSD.org>
Cc: 
Subject: Re: kern/55690 (GCC9 -pipe not working with PIPE_SOCKETPAIR)
Date: Tue, 6 Oct 2020 00:05:49 +0900

 The situation does not change even with ``memcmp'' fix for GCC 9.3.

Responsible-Changed-From-To: kern-bug-people->jdolecek
Responsible-Changed-By: jdolecek@NetBSD.org
Responsible-Changed-When: Sun, 24 Jan 2021 13:03:41 +0000
Responsible-Changed-Why:
I'll look into this eventually, looks like this might be some race
similar to PR kern/50094


State-Changed-From-To: open->feedback
State-Changed-By: jdolecek@NetBSD.org
State-Changed-When: Sun, 21 Jan 2024 18:08:29 +0000
State-Changed-Why:
The PIPE_SOCKETPAIR version of pipe1() appears to not pass correctly O_CLOEXEC and O_NONBLOCK.
O_CLOEXEC would just leak descriptors, but O_NONBLOCK might have the effect you are seeing
(processes stuck on netio).
I've prepared patch this fixes this, with this the lang/perl9 build works for me with gcc 9.3.0:
https://www.netbsd.org/~jdolecek/pipe_socketpair_fix.diff.txt

Can you check it out and see if it makes difference on your system too?
The change does also fix the lib/libc/sys/t_pipe2 failure, but does not change anything
for kernel/kqueue/write/t_pipe.


From: "Jaromir Dolecek" <jdolecek@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55690 CVS commit: src/sys
Date: Sat, 3 Feb 2024 19:05:15 +0000

 Module Name:	src
 Committed By:	jdolecek
 Date:		Sat Feb  3 19:05:15 UTC 2024

 Modified Files:
 	src/sys/kern: uipc_socket.c uipc_syscalls.c
 	src/sys/net: if_gre.c
 	src/sys/sys: socketvar.h

 Log Message:
 fix PIPE_SOCKETPAIR variant of pipe1() to apply correctly the 'flags'
 passed when called via pipe2(2), fixing repeatable process hang during
 compilation with 'gcc -pipe'

 refactor fsocreate() to return the new socket and file pointers,
 expect the caller to call fd_affix() once initialization is fully complete

 use the new fsocreate() to replace the duplicate open-coded 'flags' handling
 in makesocket() used for socketpair(2), and in the PIPE_SOCKETPAIR pipe1()

 this also fixes lib/libc/sys/t_pipe2 pipe2_cloexec test to succeed
 on PIPE_SOCKETPAIR kernel

 fixes PR kern/55690


 To generate a diff of this commit:
 cvs rdiff -u -r1.307 -r1.308 src/sys/kern/uipc_socket.c
 cvs rdiff -u -r1.210 -r1.211 src/sys/kern/uipc_syscalls.c
 cvs rdiff -u -r1.184 -r1.185 src/sys/net/if_gre.c
 cvs rdiff -u -r1.167 -r1.168 src/sys/sys/socketvar.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: feedback->pending-pullups
State-Changed-By: jdolecek@NetBSD.org
State-Changed-When: Sat, 03 Feb 2024 19:12:08 +0000
State-Changed-Why:
I've committed the proposed change. I confirmed I could repeat the issue
with unpatched kernel, and the patch fixed it.
I'm waitint for daily builds and anita tests to run, then I'll request
the pullup to 10.


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55690 CVS commit: [netbsd-10] src/sys
Date: Sun, 4 Feb 2024 11:20:15 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sun Feb  4 11:20:15 UTC 2024

 Modified Files:
 	src/sys/kern [netbsd-10]: uipc_socket.c uipc_syscalls.c
 	src/sys/net [netbsd-10]: if_gre.c
 	src/sys/sys [netbsd-10]: socketvar.h

 Log Message:
 Pull up following revision(s) (requested by jdolecek in ticket #583):

 	sys/kern/uipc_socket.c: revision 1.308
 	sys/kern/uipc_syscalls.c: revision 1.211
 	sys/sys/socketvar.h: revision 1.168
 	sys/net/if_gre.c: revision 1.185

 fix PIPE_SOCKETPAIR variant of pipe1() to apply correctly the 'flags'
 passed when called via pipe2(2), fixing repeatable process hang during
 compilation with 'gcc -pipe'

 refactor fsocreate() to return the new socket and file pointers,
 expect the caller to call fd_affix() once initialization is fully complete
 use the new fsocreate() to replace the duplicate open-coded 'flags' handling
 in makesocket() used for socketpair(2), and in the PIPE_SOCKETPAIR pipe1()
 this also fixes lib/libc/sys/t_pipe2 pipe2_cloexec test to succeed
 on PIPE_SOCKETPAIR kernel

 fixes PR kern/55690


 To generate a diff of this commit:
 cvs rdiff -u -r1.302 -r1.302.4.1 src/sys/kern/uipc_socket.c
 cvs rdiff -u -r1.206 -r1.206.4.1 src/sys/kern/uipc_syscalls.c
 cvs rdiff -u -r1.184 -r1.184.4.1 src/sys/net/if_gre.c
 cvs rdiff -u -r1.165 -r1.165.4.1 src/sys/sys/socketvar.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: jdolecek@NetBSD.org
State-Changed-When: Sun, 11 Feb 2024 13:04:05 +0000
State-Changed-Why:
The netio hang fix is pulled up to -10.
I've now also added a fix for the failing kernel/kqueue/write/t_pipe.c,
but that part is not really necessary to pullup, so leaving just on HEAD.


From: "Jaromir Dolecek" <jdolecek@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55690 CVS commit: src/sys/kern
Date: Sun, 11 Feb 2024 13:01:29 +0000

 Module Name:	src
 Committed By:	jdolecek
 Date:		Sun Feb 11 13:01:29 UTC 2024

 Modified Files:
 	src/sys/kern: uipc_socket.c

 Log Message:
 make kqfilter() behave the same for PIPE_SOCKETPAIR pipe as it does
 for standard one - refuse EVFILT_WRITE if the reader is already disconnected

 fixes test failure for kernel/kqueue/write/t_pipe.c on PIPE_SOCKETPAIR kernel

 PR kern/55690


 To generate a diff of this commit:
 cvs rdiff -u -r1.308 -r1.309 src/sys/kern/uipc_socket.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.