NetBSD Problem Report #53003

From www@NetBSD.org  Sat Feb 10 16:39:31 2018
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 A5EA37A1B3
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 10 Feb 2018 16:39:31 +0000 (UTC)
Message-Id: <20180210163930.E8B157A269@mollari.NetBSD.org>
Date: Sat, 10 Feb 2018 16:39:30 +0000 (UTC)
From: m.viey@wanadoo.fr
Reply-To: m.viey@wanadoo.fr
To: gnats-bugs@NetBSD.org
Subject: Problem with rust library using kqueue
X-Send-Pr-Version: www-1.0

>Number:         53003
>Category:       lib
>Synopsis:       Problem with rust library using kqueue
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          closed
>Class:          support
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 10 16:40:00 +0000 2018
>Closed-Date:    Fri Jun 12 17:38:49 +0000 2020
>Last-Modified:  Fri Jun 12 17:38:49 +0000 2020
>Originator:     Mickaël Viey
>Release:        pkgsrc-2017Q3
>Organization:
>Environment:
NetBSD 7.1 (GENERIC.201703111743Z) amd63
>Description:
Hi,

I experiment a problem with using rust Library which use lib kqueue. This library (https://github.com/carllerche/mio) fails with an assertion eror about EV_ERROR kqueue constant.

The error occurs at line 118 of this file https://github.com/carllerche/mio/blob/master/src/sys/unix/kqueue.rs .

I reproduce for convenience the related assert test here:

debug_assert_eq!(change.flags & libc::EV_ERROR, libc::EV_ERROR); 

I tried in FreeBSD the same library and I don't get this error.

Could you please help me with your point of vue about this behaviour ?

is this behaviour seems to you expected in Net BSD ?

I made an issue report on github repo of a lib using mio:
https://github.com/hyperium/hyper/issues/1435

>How-To-Repeat:
You could reproduce this with:
installing rust from official site:
curl https://sh.rustup.rs -sSf | sh

then you could test this code here:
https://hyper.rs/guides/server/hello-world/
>Fix:

>Release-Note:

>Audit-Trail:
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, lib-bug-people@netbsd.org, 
	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc: 
Subject: Re: lib/53003: Problem with rust library using kqueue
Date: Sat, 10 Feb 2018 20:30:29 -0500

 On Feb 10,  4:40pm, m.viey@wanadoo.fr (m.viey@wanadoo.fr) wrote:
 -- Subject: lib/53003: Problem with rust library using kqueue

 | >Number:         53003
 | >Category:       lib
 | >Synopsis:       Problem with rust library using kqueue
 | >Confidential:   no
 | >Severity:       serious
 | >Priority:       medium
 | >Responsible:    lib-bug-people
 | >State:          open
 | >Class:          support
 | >Submitter-Id:   net
 | >Arrival-Date:   Sat Feb 10 16:40:00 +0000 2018
 | >Originator:     Mickaël Viey
 | >Release:        pkgsrc-2017Q3
 | >Organization:
 | >Environment:
 | NetBSD 7.1 (GENERIC.201703111743Z) amd63
 | >Description:
 | Hi,
 | 
 | I experiment a problem with using rust Library which use lib kqueue. This library (https://github.com/carllerche/mio) fails with an assertion eror about EV_ERROR kqueue constant.
 | 
 | The error occurs at line 118 of this file https://github.com/carllerche/mio/blob/master/src/sys/unix/kqueue.rs .
 | 
 | I reproduce for convenience the related assert test here:
 | 
 | debug_assert_eq!(change.flags & libc::EV_ERROR, libc::EV_ERROR); 
 | 
 | I tried in FreeBSD the same library and I don't get this error.
 | 
 | Could you please help me with your point of vue about this behaviour ?
 | 
 | is this behaviour seems to you expected in Net BSD ?
 | 
 | I made an issue report on github repo of a lib using mio:
 | https://github.com/hyperium/hyper/issues/1435
 | 
 | >How-To-Repeat:
 | You could reproduce this with:
 | installing rust from official site:
 | curl https://sh.rustup.rs -sSf | sh
 | 
 | then you could test this code here:
 | https://hyper.rs/guides/server/hello-world/

 Works in current and I think it will also work in 8. Can you please try that?

 christos

From: Mickael Viey <m.viey@wanadoo.fr>
To: gnats-bugs@NetBSD.org, lib-bug-people@netbsd.org, gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Cc: 
Subject: Re: lib/53003: Problem with rust library using kqueue
Date: Sun, 11 Feb 2018 10:23:44 +0100

 This is a multi-part message in MIME format.
 --------------66D564FBB8EE98E945923577
 Content-Type: text/plain; charset=utf-8; format=flowed
 Content-Transfer-Encoding: 8bit


 > The following reply was made to PR lib/53003; it has been noted by GNATS.
 >
 > From: christos@zoulas.com (Christos Zoulas)
 > To: gnats-bugs@NetBSD.org, lib-bug-people@netbsd.org,
 > 	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
 > Cc:
 > Subject: Re: lib/53003: Problem with rust library using kqueue
 > Date: Sat, 10 Feb 2018 20:30:29 -0500
 >
 >   On Feb 10,  4:40pm, m.viey@wanadoo.fr (m.viey@wanadoo.fr) wrote:
 >   -- Subject: lib/53003: Problem with rust library using kqueue
 >   
 >   | >Number:         53003
 >   | >Category:       lib
 >   | >Synopsis:       Problem with rust library using kqueue
 >   | >Confidential:   no
 >   | >Severity:       serious
 >   | >Priority:       medium
 >   | >Responsible:    lib-bug-people
 >   | >State:          open
 >   | >Class:          support
 >   | >Submitter-Id:   net
 >   | >Arrival-Date:   Sat Feb 10 16:40:00 +0000 2018
 >   | >Originator:     Mickaël Viey
 >   | >Release:        pkgsrc-2017Q3
 >   | >Organization:
 >   | >Environment:
 >   | NetBSD 7.1 (GENERIC.201703111743Z) amd63
 >   | >Description:
 >   | Hi,
 >   |
 >   | I experiment a problem with using rust Library which use lib kqueue. This library (https://github.com/carllerche/mio) fails with an assertion eror about EV_ERROR kqueue constant.
 >   |
 >   | The error occurs at line 118 of this file https://github.com/carllerche/mio/blob/master/src/sys/unix/kqueue.rs .
 >   |
 >   | I reproduce for convenience the related assert test here:
 >   |
 >   | debug_assert_eq!(change.flags & libc::EV_ERROR, libc::EV_ERROR);
 >   |
 >   | I tried in FreeBSD the same library and I don't get this error.
 >   |
 >   | Could you please help me with your point of vue about this behaviour ?
 >   |
 >   | is this behaviour seems to you expected in Net BSD ?
 >   |
 >   | I made an issue report on github repo of a lib using mio:
 >   | https://github.com/hyperium/hyper/issues/1435
 >   |
 >   | >How-To-Repeat:
 >   | You could reproduce this with:
 >   | installing rust from official site:
 >   | curl https://sh.rustup.rs -sSf | sh
 >   |
 >   | then you could test this code here:
 >   | https://hyper.rs/guides/server/hello-world/
 >   
 >   Works in current and I think it will also work in 8. Can you please try that?
 >   
 >   christos
 >   
 Ok, the NetBSD in that I tried this code is my usual working machine, 
 but I will try on a VM ASAP.

 Do you know why this code fails on the stable version? (a link to a PR 
 by example)

 Thanks for your reply(, and sorry for the typing error on uname.)



 --------------66D564FBB8EE98E945923577
 Content-Type: text/html; charset=utf-8
 Content-Transfer-Encoding: 8bit

 <html>
   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   </head>
   <body text="#333333" bgcolor="#CCCCCC">
     <br>
     <blockquote type="cite"
       cite="mid:20180211013501.0399D7A269@mollari.NetBSD.org">
       <pre wrap="">The following reply was made to PR lib/53003; it has been noted by GNATS.

 From: <a class="moz-txt-link-abbreviated" href="mailto:christos@zoulas.com">christos@zoulas.com</a> (Christos Zoulas)
 To: <a class="moz-txt-link-abbreviated" href="mailto:gnats-bugs@NetBSD.org">gnats-bugs@NetBSD.org</a>, <a class="moz-txt-link-abbreviated" href="mailto:lib-bug-people@netbsd.org">lib-bug-people@netbsd.org</a>, 
 	<a class="moz-txt-link-abbreviated" href="mailto:gnats-admin@netbsd.org">gnats-admin@netbsd.org</a>, <a class="moz-txt-link-abbreviated" href="mailto:netbsd-bugs@netbsd.org">netbsd-bugs@netbsd.org</a>
 Cc: 
 Subject: Re: lib/53003: Problem with rust library using kqueue
 Date: Sat, 10 Feb 2018 20:30:29 -0500

  On Feb 10,  4:40pm, <a class="moz-txt-link-abbreviated" href="mailto:m.viey@wanadoo.fr">m.viey@wanadoo.fr</a> (<a class="moz-txt-link-abbreviated" href="mailto:m.viey@wanadoo.fr">m.viey@wanadoo.fr</a>) wrote:
  -- Subject: lib/53003: Problem with rust library using kqueue

  | &gt;Number:         53003
  | &gt;Category:       lib
  | &gt;Synopsis:       Problem with rust library using kqueue
  | &gt;Confidential:   no
  | &gt;Severity:       serious
  | &gt;Priority:       medium
  | &gt;Responsible:    lib-bug-people
  | &gt;State:          open
  | &gt;Class:          support
  | &gt;Submitter-Id:   net
  | &gt;Arrival-Date:   Sat Feb 10 16:40:00 +0000 2018
  | &gt;Originator:     Mickaël Viey
  | &gt;Release:        pkgsrc-2017Q3
  | &gt;Organization:
  | &gt;Environment:
  | NetBSD 7.1 (GENERIC.201703111743Z) amd63
  | &gt;Description:
  | Hi,
  | 
  | I experiment a problem with using rust Library which use lib kqueue. This library (<a class="moz-txt-link-freetext" href="https://github.com/carllerche/mio">https://github.com/carllerche/mio</a>) fails with an assertion eror about EV_ERROR kqueue constant.
  | 
  | The error occurs at line 118 of this file <a class="moz-txt-link-freetext" href="https://github.com/carllerche/mio/blob/master/src/sys/unix/kqueue.rs">https://github.com/carllerche/mio/blob/master/src/sys/unix/kqueue.rs</a> .
  | 
  | I reproduce for convenience the related assert test here:
  | 
  | debug_assert_eq!(change.flags &amp; libc::EV_ERROR, libc::EV_ERROR); 
  | 
  | I tried in FreeBSD the same library and I don't get this error.
  | 
  | Could you please help me with your point of vue about this behaviour ?
  | 
  | is this behaviour seems to you expected in Net BSD ?
  | 
  | I made an issue report on github repo of a lib using mio:
  | <a class="moz-txt-link-freetext" href="https://github.com/hyperium/hyper/issues/1435">https://github.com/hyperium/hyper/issues/1435</a>
  | 
  | &gt;How-To-Repeat:
  | You could reproduce this with:
  | installing rust from official site:
  | curl <a class="moz-txt-link-freetext" href="https://sh.rustup.rs">https://sh.rustup.rs</a> -sSf | sh
  | 
  | then you could test this code here:
  | <a class="moz-txt-link-freetext" href="https://hyper.rs/guides/server/hello-world/">https://hyper.rs/guides/server/hello-world/</a>

  Works in current and I think it will also work in 8. Can you please try that?

  christos

 </pre>
     </blockquote>
     Ok, the NetBSD in that I tried this code is my usual working
     machine, but I will try on a VM ASAP.<span id="result_box" class=""
       lang="en"><span class=""><br>
         <br>
         Do you know why this code fails on the stable version? (a link
         to a PR by example)<br>
         <br>
         Thanks for your reply(, and sorry for the typing error on
         uname.)<br>
         <br>
         <br>
       </span></span>
   </body>
 </html>

 --------------66D564FBB8EE98E945923577--

From: christos@zoulas.com (Christos Zoulas)
To: Mickael Viey <m.viey@wanadoo.fr>, gnats-bugs@NetBSD.org, 
	lib-bug-people@netbsd.org, gnats-admin@netbsd.org, 
	netbsd-bugs@netbsd.org
Cc: 
Subject: Re: lib/53003: Problem with rust library using kqueue
Date: Sun, 11 Feb 2018 11:08:19 -0500

 On Feb 11, 10:23am, m.viey@wanadoo.fr (Mickael Viey) wrote:
 -- Subject: Re: lib/53003: Problem with rust library using kqueue

 | Ok, the NetBSD in that I tried this code is my usual working machine, 
 | but I will try on a VM ASAP.
 | 
 | Do you know why this code fails on the stable version? (a link to a PR 
 | by example)
 | 
 | Thanks for your reply(, and sorry for the typing error on uname.)

 I am not sure. One thing to try is to apply the diff from
 of kern_event.c HEAD to the netbsd-7 branch and change f_kqueue -> f_data
 so that it compiles. The other thing you can do is to ktrace the binary
 to see where it fails. My guess is that if fails because of the following.
 Try it, and if it works I will ask for a pullup.

 christos

 revision 1.198
 date: 2017-07-01 16:07:00 -0400;  author: christos;  state: Exp;  lines: +33 -2;
 Provide EVFILT_WRITE; this is what FreeBSD does and go wants it.
 Makes go unit tests pass.


 Index: genfs_vnops.c
 ===================================================================
 RCS file: /cvsroot/src/sys/miscfs/genfs/genfs_vnops.c,v
 retrieving revision 1.197
 retrieving revision 1.198
 diff -u -r1.197 -r1.198
 --- genfs_vnops.c	4 Jun 2017 08:02:26 -0000	1.197
 +++ genfs_vnops.c	1 Jul 2017 20:07:00 -0000	1.198
 @@ -1,4 +1,4 @@
 -/*	$NetBSD: genfs_vnops.c,v 1.197 2017/06/04 08:02:26 hannken Exp $	*/
 +/*	$NetBSD: genfs_vnops.c,v 1.198 2017/07/01 20:07:00 christos Exp $	*/

  /*-
   * Copyright (c) 2008 The NetBSD Foundation, Inc.
 @@ -57,7 +57,7 @@
   */

  #include <sys/cdefs.h>
 -__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.197 2017/06/04 08:02:26 hannken Exp $");
 +__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.198 2017/07/01 20:07:00 christos Exp $");

  #include <sys/param.h>
  #include <sys/systm.h>
 @@ -500,6 +500,32 @@
  }

  static int
 +filt_genfswrite(struct knote *kn, long hint)
 +{
 +	struct vnode *vp = (struct vnode *)kn->kn_hook;
 +
 +	/*
 +	 * filesystem is gone, so set the EOF flag and schedule
 +	 * the knote for deletion.
 +	 */
 +	switch (hint) {
 +	case NOTE_REVOKE:
 +		KASSERT(mutex_owned(vp->v_interlock));
 +		kn->kn_flags |= (EV_EOF | EV_ONESHOT);
 +		return (1);
 +	case 0:
 +		mutex_enter(vp->v_interlock);
 +		kn->kn_data = 0;
 +		mutex_exit(vp->v_interlock);
 +		return 1;
 +	default:
 +		KASSERT(mutex_owned(vp->v_interlock));
 +		kn->kn_data = 0;
 +		return 1;
 +	}
 +}
 +
 +static int
  filt_genfsvnode(struct knote *kn, long hint)
  {
  	struct vnode *vp = (struct vnode *)kn->kn_hook;
 @@ -530,6 +556,8 @@

  static const struct filterops genfsread_filtops =
  	{ 1, NULL, filt_genfsdetach, filt_genfsread };
 +static const struct filterops genfswrite_filtops =
 +	{ 1, NULL, filt_genfsdetach, filt_genfswrite };
  static const struct filterops genfsvnode_filtops =
  	{ 1, NULL, filt_genfsdetach, filt_genfsvnode };

 @@ -549,6 +577,9 @@
  	case EVFILT_READ:
  		kn->kn_fop = &genfsread_filtops;
  		break;
 +	case EVFILT_WRITE:
 +		kn->kn_fop = &genfswrite_filtops;
 +		break;
  	case EVFILT_VNODE:
  		kn->kn_fop = &genfsvnode_filtops;
  		break;

From: Mickael Viey <m.viey@wanadoo.fr>
To: gnats-bugs@NetBSD.org, lib-bug-people@netbsd.org, gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Cc: 
Subject: Re: lib/53003: Problem with rust library using kqueue
Date: Sun, 11 Feb 2018 21:58:44 +0100

 > The following reply was made to PR lib/53003; it has been noted by GNATS.
 >
 > From: christos@zoulas.com (Christos Zoulas)
 > To: Mickael Viey <m.viey@wanadoo.fr>, gnats-bugs@NetBSD.org,
 > 	lib-bug-people@netbsd.org, gnats-admin@netbsd.org,
 > 	netbsd-bugs@netbsd.org
 > Cc:
 > Subject: Re: lib/53003: Problem with rust library using kqueue
 > Date: Sun, 11 Feb 2018 11:08:19 -0500
 >
 >   On Feb 11, 10:23am, m.viey@wanadoo.fr (Mickael Viey) wrote:
 >   -- Subject: Re: lib/53003: Problem with rust library using kqueue
 >   
 >   | Ok, the NetBSD in that I tried this code is my usual working machine,
 >   | but I will try on a VM ASAP.
 >   |
 >   | Do you know why this code fails on the stable version? (a link to a PR
 >   | by example)
 >   |
 >   | Thanks for your reply(, and sorry for the typing error on uname.)
 >   
 >   I am not sure. One thing to try is to apply the diff from
 >   of kern_event.c HEAD to the netbsd-7 branch and change f_kqueue -> f_data
 >   so that it compiles. The other thing you can do is to ktrace the binary
 >   to see where it fails. My guess is that if fails because of the following.
 >   Try it, and if it works I will ask for a pullup.
 >   
 >   christos
 >   
 >   revision 1.198
 >   date: 2017-07-01 16:07:00 -0400;  author: christos;  state: Exp;  lines: +33 -2;
 >   Provide EVFILT_WRITE; this is what FreeBSD does and go wants it.
 >   Makes go unit tests pass.
 >   
 >   
 >   Index: genfs_vnops.c
 >   ===================================================================
 >   RCS file: /cvsroot/src/sys/miscfs/genfs/genfs_vnops.c,v
 >   retrieving revision 1.197
 >   retrieving revision 1.198
 >   diff -u -r1.197 -r1.198
 >   --- genfs_vnops.c	4 Jun 2017 08:02:26 -0000	1.197
 >   +++ genfs_vnops.c	1 Jul 2017 20:07:00 -0000	1.198
 >   @@ -1,4 +1,4 @@
 >   -/*	$NetBSD: genfs_vnops.c,v 1.197 2017/06/04 08:02:26 hannken Exp $	*/
 >   +/*	$NetBSD: genfs_vnops.c,v 1.198 2017/07/01 20:07:00 christos Exp $	*/
 >    
 >    /*-
 >     * Copyright (c) 2008 The NetBSD Foundation, Inc.
 >   @@ -57,7 +57,7 @@
 >     */
 >    
 >    #include <sys/cdefs.h>
 >   -__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.197 2017/06/04 08:02:26 hannken Exp $");
 >   +__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.198 2017/07/01 20:07:00 christos Exp $");
 >    
 >    #include <sys/param.h>
 >    #include <sys/systm.h>
 >   @@ -500,6 +500,32 @@
 >    }
 >    
 >    static int
 >   +filt_genfswrite(struct knote *kn, long hint)
 >   +{
 >   +	struct vnode *vp = (struct vnode *)kn->kn_hook;
 >   +
 >   +	/*
 >   +	 * filesystem is gone, so set the EOF flag and schedule
 >   +	 * the knote for deletion.
 >   +	 */
 >   +	switch (hint) {
 >   +	case NOTE_REVOKE:
 >   +		KASSERT(mutex_owned(vp->v_interlock));
 >   +		kn->kn_flags |= (EV_EOF | EV_ONESHOT);
 >   +		return (1);
 >   +	case 0:
 >   +		mutex_enter(vp->v_interlock);
 >   +		kn->kn_data = 0;
 >   +		mutex_exit(vp->v_interlock);
 >   +		return 1;
 >   +	default:
 >   +		KASSERT(mutex_owned(vp->v_interlock));
 >   +		kn->kn_data = 0;
 >   +		return 1;
 >   +	}
 >   +}
 >   +
 >   +static int
 >    filt_genfsvnode(struct knote *kn, long hint)
 >    {
 >    	struct vnode *vp = (struct vnode *)kn->kn_hook;
 >   @@ -530,6 +556,8 @@
 >    
 >    static const struct filterops genfsread_filtops =
 >    	{ 1, NULL, filt_genfsdetach, filt_genfsread };
 >   +static const struct filterops genfswrite_filtops =
 >   +	{ 1, NULL, filt_genfsdetach, filt_genfswrite };
 >    static const struct filterops genfsvnode_filtops =
 >    	{ 1, NULL, filt_genfsdetach, filt_genfsvnode };
 >    
 >   @@ -549,6 +577,9 @@
 >    	case EVFILT_READ:
 >    		kn->kn_fop = &genfsread_filtops;
 >    		break;
 >   +	case EVFILT_WRITE:
 >   +		kn->kn_fop = &genfswrite_filtops;
 >   +		break;
 >    	case EVFILT_VNODE:
 >    		kn->kn_fop = &genfsvnode_filtops;
 >    		break;
 >   
 Thanks, I will try to adapt the rust library to NetBSD way. I got a a 
 mio copy from github. With your indications, an kqueue documentation 
 reading I will perhaps find how I can work around this bug. In the same 
 time I will try to understand what is different in NetBSD kqueue 
 compared to FreeBSD.

 Best,


 Mickaël

From: Mickael Viey <m.viey@wanadoo.fr>
To: gnats-bugs@NetBSD.org, lib-bug-people@netbsd.org, gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Cc: 
Subject: Re: lib/53003: Problem with rust library using kqueue
Date: Sat, 17 Feb 2018 12:05:45 +0100

 > The following reply was made to PR lib/53003; it has been noted by GNATS.
 >
 > From: christos@zoulas.com (Christos Zoulas)
 > To: Mickael Viey <m.viey@wanadoo.fr>, gnats-bugs@NetBSD.org,
 > 	lib-bug-people@netbsd.org, gnats-admin@netbsd.org,
 > 	netbsd-bugs@netbsd.org
 > Cc:
 > Subject: Re: lib/53003: Problem with rust library using kqueue
 > Date: Sun, 11 Feb 2018 11:08:19 -0500
 >
 >   On Feb 11, 10:23am, m.viey@wanadoo.fr (Mickael Viey) wrote:
 >   -- Subject: Re: lib/53003: Problem with rust library using kqueue
 >   
 >   | Ok, the NetBSD in that I tried this code is my usual working machine,
 >   | but I will try on a VM ASAP.
 >   |
 >   | Do you know why this code fails on the stable version? (a link to a PR
 >   | by example)
 >   |
 >   | Thanks for your reply(, and sorry for the typing error on uname.)
 >   
 >   I am not sure. One thing to try is to apply the diff from
 >   of kern_event.c HEAD to the netbsd-7 branch and change f_kqueue -> f_data
 >   so that it compiles. The other thing you can do is to ktrace the binary
 >   to see where it fails. My guess is that if fails because of the following.
 >   Try it, and if it works I will ask for a pullup.
 >   
 >   christos
 >   
 >   revision 1.198
 >   date: 2017-07-01 16:07:00 -0400;  author: christos;  state: Exp;  lines: +33 -2;
 >   Provide EVFILT_WRITE; this is what FreeBSD does and go wants it.
 >   Makes go unit tests pass.
 >   
 >   
 >   Index: genfs_vnops.c
 >   ===================================================================
 >   RCS file: /cvsroot/src/sys/miscfs/genfs/genfs_vnops.c,v
 >   retrieving revision 1.197
 >   retrieving revision 1.198
 >   diff -u -r1.197 -r1.198
 >   --- genfs_vnops.c	4 Jun 2017 08:02:26 -0000	1.197
 >   +++ genfs_vnops.c	1 Jul 2017 20:07:00 -0000	1.198
 >   @@ -1,4 +1,4 @@
 >   -/*	$NetBSD: genfs_vnops.c,v 1.197 2017/06/04 08:02:26 hannken Exp $	*/
 >   +/*	$NetBSD: genfs_vnops.c,v 1.198 2017/07/01 20:07:00 christos Exp $	*/
 >    
 >    /*-
 >     * Copyright (c) 2008 The NetBSD Foundation, Inc.
 >   @@ -57,7 +57,7 @@
 >     */
 >    
 >    #include <sys/cdefs.h>
 >   -__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.197 2017/06/04 08:02:26 hannken Exp $");
 >   +__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.198 2017/07/01 20:07:00 christos Exp $");
 >    
 >    #include <sys/param.h>
 >    #include <sys/systm.h>
 >   @@ -500,6 +500,32 @@
 >    }
 >    
 >    static int
 >   +filt_genfswrite(struct knote *kn, long hint)
 >   +{
 >   +	struct vnode *vp = (struct vnode *)kn->kn_hook;
 >   +
 >   +	/*
 >   +	 * filesystem is gone, so set the EOF flag and schedule
 >   +	 * the knote for deletion.
 >   +	 */
 >   +	switch (hint) {
 >   +	case NOTE_REVOKE:
 >   +		KASSERT(mutex_owned(vp->v_interlock));
 >   +		kn->kn_flags |= (EV_EOF | EV_ONESHOT);
 >   +		return (1);
 >   +	case 0:
 >   +		mutex_enter(vp->v_interlock);
 >   +		kn->kn_data = 0;
 >   +		mutex_exit(vp->v_interlock);
 >   +		return 1;
 >   +	default:
 >   +		KASSERT(mutex_owned(vp->v_interlock));
 >   +		kn->kn_data = 0;
 >   +		return 1;
 >   +	}
 >   +}
 >   +
 >   +static int
 >    filt_genfsvnode(struct knote *kn, long hint)
 >    {
 >    	struct vnode *vp = (struct vnode *)kn->kn_hook;
 >   @@ -530,6 +556,8 @@
 >    
 >    static const struct filterops genfsread_filtops =
 >    	{ 1, NULL, filt_genfsdetach, filt_genfsread };
 >   +static const struct filterops genfswrite_filtops =
 >   +	{ 1, NULL, filt_genfsdetach, filt_genfswrite };
 >    static const struct filterops genfsvnode_filtops =
 >    	{ 1, NULL, filt_genfsdetach, filt_genfsvnode };
 >    
 >   @@ -549,6 +577,9 @@
 >    	case EVFILT_READ:
 >    		kn->kn_fop = &genfsread_filtops;
 >    		break;
 >   +	case EVFILT_WRITE:
 >   +		kn->kn_fop = &genfswrite_filtops;
 >   +		break;
 >    	case EVFILT_VNODE:
 >    		kn->kn_fop = &genfsvnode_filtops;
 >    		break;
 >   
 Hi,

 Sorry for the delay. I could test the related code on NetBSD localhost 
 8.0_BETA NetBSD 8.0_BETA (GENERIC.201801282150Z) amd64. It works 
 perfectly on this release.

 I will test to recompile a version with your patch.

 Thx

From: Mickael Viey <m.viey@wanadoo.fr>
To: gnats-bugs@NetBSD.org, lib-bug-people@netbsd.org, gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Cc: 
Subject: Re: lib/53003: Problem with rust library using kqueue
Date: Sat, 17 Feb 2018 21:03:40 +0100

 This is a multi-part message in MIME format.
 --------------D862FF91F5BE7956B1E84E94
 Content-Type: text/plain; charset=utf-8; format=flowed
 Content-Transfer-Encoding: 8bit

 Hello,


 Finally I build a new kernel from netbsd-7 branch where you patch was 
 been backported.

 and code given in example work on this new kernel.


 Thx for your help.


 Best,


 Mickaël


 Le 11/02/2018 à 17:10, Christos Zoulas a écrit :
 > The following reply was made to PR lib/53003; it has been noted by GNATS.
 >
 > From: christos@zoulas.com (Christos Zoulas)
 > To: Mickael Viey <m.viey@wanadoo.fr>, gnats-bugs@NetBSD.org,
 > 	lib-bug-people@netbsd.org, gnats-admin@netbsd.org,
 > 	netbsd-bugs@netbsd.org
 > Cc:
 > Subject: Re: lib/53003: Problem with rust library using kqueue
 > Date: Sun, 11 Feb 2018 11:08:19 -0500
 >
 >   On Feb 11, 10:23am, m.viey@wanadoo.fr (Mickael Viey) wrote:
 >   -- Subject: Re: lib/53003: Problem with rust library using kqueue
 >   
 >   | Ok, the NetBSD in that I tried this code is my usual working machine,
 >   | but I will try on a VM ASAP.
 >   |
 >   | Do you know why this code fails on the stable version? (a link to a PR
 >   | by example)
 >   |
 >   | Thanks for your reply(, and sorry for the typing error on uname.)
 >   
 >   I am not sure. One thing to try is to apply the diff from
 >   of kern_event.c HEAD to the netbsd-7 branch and change f_kqueue -> f_data
 >   so that it compiles. The other thing you can do is to ktrace the binary
 >   to see where it fails. My guess is that if fails because of the following.
 >   Try it, and if it works I will ask for a pullup.
 >   
 >   christos
 >   
 >   revision 1.198
 >   date: 2017-07-01 16:07:00 -0400;  author: christos;  state: Exp;  lines: +33 -2;
 >   Provide EVFILT_WRITE; this is what FreeBSD does and go wants it.
 >   Makes go unit tests pass.
 >   
 >   
 >   Index: genfs_vnops.c
 >   ===================================================================
 >   RCS file: /cvsroot/src/sys/miscfs/genfs/genfs_vnops.c,v
 >   retrieving revision 1.197
 >   retrieving revision 1.198
 >   diff -u -r1.197 -r1.198
 >   --- genfs_vnops.c	4 Jun 2017 08:02:26 -0000	1.197
 >   +++ genfs_vnops.c	1 Jul 2017 20:07:00 -0000	1.198
 >   @@ -1,4 +1,4 @@
 >   -/*	$NetBSD: genfs_vnops.c,v 1.197 2017/06/04 08:02:26 hannken Exp $	*/
 >   +/*	$NetBSD: genfs_vnops.c,v 1.198 2017/07/01 20:07:00 christos Exp $	*/
 >    
 >    /*-
 >     * Copyright (c) 2008 The NetBSD Foundation, Inc.
 >   @@ -57,7 +57,7 @@
 >     */
 >    
 >    #include <sys/cdefs.h>
 >   -__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.197 2017/06/04 08:02:26 hannken Exp $");
 >   +__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.198 2017/07/01 20:07:00 christos Exp $");
 >    
 >    #include <sys/param.h>
 >    #include <sys/systm.h>
 >   @@ -500,6 +500,32 @@
 >    }
 >    
 >    static int
 >   +filt_genfswrite(struct knote *kn, long hint)
 >   +{
 >   +	struct vnode *vp = (struct vnode *)kn->kn_hook;
 >   +
 >   +	/*
 >   +	 * filesystem is gone, so set the EOF flag and schedule
 >   +	 * the knote for deletion.
 >   +	 */
 >   +	switch (hint) {
 >   +	case NOTE_REVOKE:
 >   +		KASSERT(mutex_owned(vp->v_interlock));
 >   +		kn->kn_flags |= (EV_EOF | EV_ONESHOT);
 >   +		return (1);
 >   +	case 0:
 >   +		mutex_enter(vp->v_interlock);
 >   +		kn->kn_data = 0;
 >   +		mutex_exit(vp->v_interlock);
 >   +		return 1;
 >   +	default:
 >   +		KASSERT(mutex_owned(vp->v_interlock));
 >   +		kn->kn_data = 0;
 >   +		return 1;
 >   +	}
 >   +}
 >   +
 >   +static int
 >    filt_genfsvnode(struct knote *kn, long hint)
 >    {
 >    	struct vnode *vp = (struct vnode *)kn->kn_hook;
 >   @@ -530,6 +556,8 @@
 >    
 >    static const struct filterops genfsread_filtops =
 >    	{ 1, NULL, filt_genfsdetach, filt_genfsread };
 >   +static const struct filterops genfswrite_filtops =
 >   +	{ 1, NULL, filt_genfsdetach, filt_genfswrite };
 >    static const struct filterops genfsvnode_filtops =
 >    	{ 1, NULL, filt_genfsdetach, filt_genfsvnode };
 >    
 >   @@ -549,6 +577,9 @@
 >    	case EVFILT_READ:
 >    		kn->kn_fop = &genfsread_filtops;
 >    		break;
 >   +	case EVFILT_WRITE:
 >   +		kn->kn_fop = &genfswrite_filtops;
 >   +		break;
 >    	case EVFILT_VNODE:
 >    		kn->kn_fop = &genfsvnode_filtops;
 >    		break;
 >   


 --------------D862FF91F5BE7956B1E84E94
 Content-Type: text/html; charset=utf-8
 Content-Transfer-Encoding: 8bit

 <html>
   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   </head>
   <body text="#333333" bgcolor="#CCCCCC">
     <p>Hello,</p>
     <p><br>
     </p>
     <p>Finally I build a new kernel from netbsd-7 branch where you patch
       was been backported.</p>
     <p>and code given in example work on this new kernel.</p>
     <p><br>
     </p>
     <p>Thx for your help.</p>
     <p><br>
     </p>
     <p>Best,</p>
     <p><br>
     </p>
     <p>Mickaël<br>
     </p>
     <br>
     <div class="moz-cite-prefix">Le 11/02/2018 à 17:10, Christos Zoulas
       a écrit :<br>
     </div>
     <blockquote type="cite"
       cite="mid:20180211161001.3037C7A264@mollari.NetBSD.org">
       <pre wrap="">The following reply was made to PR lib/53003; it has been noted by GNATS.

 From: <a class="moz-txt-link-abbreviated" href="mailto:christos@zoulas.com">christos@zoulas.com</a> (Christos Zoulas)
 To: Mickael Viey <a class="moz-txt-link-rfc2396E" href="mailto:m.viey@wanadoo.fr">&lt;m.viey@wanadoo.fr&gt;</a>, <a class="moz-txt-link-abbreviated" href="mailto:gnats-bugs@NetBSD.org">gnats-bugs@NetBSD.org</a>, 
 	<a class="moz-txt-link-abbreviated" href="mailto:lib-bug-people@netbsd.org">lib-bug-people@netbsd.org</a>, <a class="moz-txt-link-abbreviated" href="mailto:gnats-admin@netbsd.org">gnats-admin@netbsd.org</a>, 
 	<a class="moz-txt-link-abbreviated" href="mailto:netbsd-bugs@netbsd.org">netbsd-bugs@netbsd.org</a>
 Cc: 
 Subject: Re: lib/53003: Problem with rust library using kqueue
 Date: Sun, 11 Feb 2018 11:08:19 -0500

  On Feb 11, 10:23am, <a class="moz-txt-link-abbreviated" href="mailto:m.viey@wanadoo.fr">m.viey@wanadoo.fr</a> (Mickael Viey) wrote:
  -- Subject: Re: lib/53003: Problem with rust library using kqueue

  | Ok, the NetBSD in that I tried this code is my usual working machine, 
  | but I will try on a VM ASAP.
  | 
  | Do you know why this code fails on the stable version? (a link to a PR 
  | by example)
  | 
  | Thanks for your reply(, and sorry for the typing error on uname.)

  I am not sure. One thing to try is to apply the diff from
  of kern_event.c HEAD to the netbsd-7 branch and change f_kqueue -&gt; f_data
  so that it compiles. The other thing you can do is to ktrace the binary
  to see where it fails. My guess is that if fails because of the following.
  Try it, and if it works I will ask for a pullup.

  christos

  revision 1.198
  date: 2017-07-01 16:07:00 -0400;  author: christos;  state: Exp;  lines: +33 -2;
  Provide EVFILT_WRITE; this is what FreeBSD does and go wants it.
  Makes go unit tests pass.


  Index: genfs_vnops.c
  ===================================================================
  RCS file: /cvsroot/src/sys/miscfs/genfs/genfs_vnops.c,v
  retrieving revision 1.197
  retrieving revision 1.198
  diff -u -r1.197 -r1.198
  --- genfs_vnops.c	4 Jun 2017 08:02:26 -0000	1.197
  +++ genfs_vnops.c	1 Jul 2017 20:07:00 -0000	1.198
  @@ -1,4 +1,4 @@
  -/*	$NetBSD: genfs_vnops.c,v 1.197 2017/06/04 08:02:26 hannken Exp $	*/
  +/*	$NetBSD: genfs_vnops.c,v 1.198 2017/07/01 20:07:00 christos Exp $	*/

   /*-
    * Copyright (c) 2008 The NetBSD Foundation, Inc.
  @@ -57,7 +57,7 @@
    */

   #include &lt;sys/cdefs.h&gt;
  -__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.197 2017/06/04 08:02:26 hannken Exp $");
  +__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.198 2017/07/01 20:07:00 christos Exp $");

   #include &lt;sys/param.h&gt;
   #include &lt;sys/systm.h&gt;
  @@ -500,6 +500,32 @@
   }

   static int
  +filt_genfswrite(struct knote *kn, long hint)
  +{
  +	struct vnode *vp = (struct vnode *)kn-&gt;kn_hook;
  +
  +	/*
  +	 * filesystem is gone, so set the EOF flag and schedule
  +	 * the knote for deletion.
  +	 */
  +	switch (hint) {
  +	case NOTE_REVOKE:
  +		KASSERT(mutex_owned(vp-&gt;v_interlock));
  +		kn-&gt;kn_flags |= (EV_EOF | EV_ONESHOT);
  +		return (1);
  +	case 0:
  +		mutex_enter(vp-&gt;v_interlock);
  +		kn-&gt;kn_data = 0;
  +		mutex_exit(vp-&gt;v_interlock);
  +		return 1;
  +	default:
  +		KASSERT(mutex_owned(vp-&gt;v_interlock));
  +		kn-&gt;kn_data = 0;
  +		return 1;
  +	}
  +}
  +
  +static int
   filt_genfsvnode(struct knote *kn, long hint)
   {
   	struct vnode *vp = (struct vnode *)kn-&gt;kn_hook;
  @@ -530,6 +556,8 @@

   static const struct filterops genfsread_filtops =
   	{ 1, NULL, filt_genfsdetach, filt_genfsread };
  +static const struct filterops genfswrite_filtops =
  +	{ 1, NULL, filt_genfsdetach, filt_genfswrite };
   static const struct filterops genfsvnode_filtops =
   	{ 1, NULL, filt_genfsdetach, filt_genfsvnode };

  @@ -549,6 +577,9 @@
   	case EVFILT_READ:
   		kn-&gt;kn_fop = &amp;genfsread_filtops;
   		break;
  +	case EVFILT_WRITE:
  +		kn-&gt;kn_fop = &amp;genfswrite_filtops;
  +		break;
   	case EVFILT_VNODE:
   		kn-&gt;kn_fop = &amp;genfsvnode_filtops;
   		break;

 </pre>
     </blockquote>
     <br>
   </body>
 </html>

 --------------D862FF91F5BE7956B1E84E94--

State-Changed-From-To: open->feedback
State-Changed-By: maya@NetBSD.org
State-Changed-When: Sun, 03 Jun 2018 22:02:09 +0000
State-Changed-Why:
Christos provided a newer backport patch and requested feedback on it.


State-Changed-From-To: feedback->needs-pullups
State-Changed-By: maya@NetBSD.org
State-Changed-When: Sun, 03 Jun 2018 22:13:33 +0000
State-Changed-Why:
Put in the right state, patch does work. Thanks for the quick feedback.


From: Mickael Viey <m.viey@wanadoo.fr>
To: gnats-bugs@NetBSD.org, lib-bug-people@netbsd.org, netbsd-bugs@netbsd.org,
 gnats-admin@netbsd.org, maya@NetBSD.org
Cc: 
Subject: Re: lib/53003 (Problem with rust library using kqueue)
Date: Mon, 4 Jun 2018 00:10:36 +0200

 This is a multi-part message in MIME format.
 --------------652BFE58B88C3E44FAAB917C
 Content-Type: text/plain; charset=utf-8; format=flowed
 Content-Transfer-Encoding: 8bit

 Hello,

 I provided feedback on February 17:

  > Finally I build a new kernel from netbsd-7 branch where you patch was 
 been backported.

  > and code given in example work on this new kernel.

 It works on new kernel.


 Le 04/06/2018 à 00:02, maya@NetBSD.org a écrit :
 > Synopsis: Problem with rust library using kqueue
 >
 > State-Changed-From-To: open->feedback
 > State-Changed-By: maya@NetBSD.org
 > State-Changed-When: Sun, 03 Jun 2018 22:02:09 +0000
 > State-Changed-Why:
 > Christos provided a newer backport patch and requested feedback on it.
 >
 >
 >


 --------------652BFE58B88C3E44FAAB917C
 Content-Type: text/html; charset=utf-8
 Content-Transfer-Encoding: 8bit

 <html>
   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   </head>
   <body text="#333333" bgcolor="#CCCCCC">
     <p>Hello,<br>
     </p>
     <p>I provided feedback on February 17:</p>
     <p>&gt; Finally I build a new kernel from netbsd-7 branch where you
       patch was been backported.<br>
     </p>
     <p>&gt; and code given in example work on this new kernel.</p>
     <p>It works on new kernel.<br>
     </p>
     <br>
     <div class="moz-cite-prefix">Le 04/06/2018 à 00:02, <a class="moz-txt-link-abbreviated" href="mailto:maya@NetBSD.org">maya@NetBSD.org</a>
       a écrit :<br>
     </div>
     <blockquote type="cite"
       cite="mid:20180603220210.04DA87A1DF@mollari.NetBSD.org">
       <pre wrap="">Synopsis: Problem with rust library using kqueue

 State-Changed-From-To: open-&gt;feedback
 State-Changed-By: <a class="moz-txt-link-abbreviated" href="mailto:maya@NetBSD.org">maya@NetBSD.org</a>
 State-Changed-When: Sun, 03 Jun 2018 22:02:09 +0000
 State-Changed-Why:
 Christos provided a newer backport patch and requested feedback on it.



 </pre>
     </blockquote>
     <br>
   </body>
 </html>

 --------------652BFE58B88C3E44FAAB917C--

State-Changed-From-To: needs-pullups->closed
State-Changed-By: maya@NetBSD.org
State-Changed-When: Fri, 12 Jun 2020 17:38:49 +0000
State-Changed-Why:
pulled up in pullup-7 #1442. thanks for the report.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.