NetBSD Problem Report #50780
From www@NetBSD.org Sun Feb 7 23:48:33 2016
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 "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id CC14F7ABF7
for <gnats-bugs@gnats.NetBSD.org>; Sun, 7 Feb 2016 23:48:33 +0000 (UTC)
Message-Id: <20160207234832.8659C7ACBC@mollari.NetBSD.org>
Date: Sun, 7 Feb 2016 23:48:32 +0000 (UTC)
From: Tr@visPaul.me
Reply-To: Tr@visPaul.me
To: gnats-bugs@NetBSD.org
Subject: net/zeromq broken on NetBSD current
X-Send-Pr-Version: www-1.0
>Number: 50780
>Category: pkg
>Synopsis: net/zeromq broken on NetBSD current
>Confidential: no
>Severity: critical
>Priority: low
>Responsible: pkg-manager
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Feb 07 23:50:00 +0000 2016
>Closed-Date: Tue Apr 05 06:09:27 +0000 2016
>Last-Modified: Tue Apr 05 14:10:01 +0000 2016
>Originator: Travis Paul
>Release: current
>Organization:
>Environment:
NetBSD kagato.netverb.com 7.99.26 NetBSD 7.99.26 (kagato) #0: Sun Feb 7 11:33:50 EST 2016 tpaul@kagato.netverb.com:/build/obj/sys/arch/amd64/compile/kagato amd64
>Description:
zeromq crashes on NetBSD current when calling pthread_setschedparam
Attached is a patch which works around this issue, by simply removing the function call as it does not appear to be essential for normal operation. This allows zeromq and py27-zmq to work as expected however it may not be the ideal approach.
This issue appears to be specific to NetBSD-current and does not appear to affect OS X or SmartOS when using pkgsrc.
>How-To-Repeat:
The following examples will fail with:
Invalid argument (src/thread.cpp:135)
Abort (core dumped)
Sample app using libzmq:
#include <zmq.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
int main (void)
{
void *context = zmq_ctx_new ();
void *responder = zmq_socket (context, ZMQ_REP);
int rc = zmq_bind (responder, "tcp://*:5555");
assert (rc == 0);
while (1) {
char buffer [10];
zmq_recv (responder, buffer, 10, 0);
printf ("Received Hello\n");
sleep (1); // Do some 'work'
zmq_send (responder, "World", 5, 0);
}
return 0;
}
or via python2.7:
import zmq
ctx = zmq.Context()
ctx.socket(zmq.PUB)
>Fix:
Index: distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/net/zeromq/distinfo,v
retrieving revision 1.19
diff -u -r1.19 distinfo
--- distinfo 24 Nov 2015 11:01:34 -0000 1.19
+++ distinfo 7 Feb 2016 23:45:07 -0000
@@ -9,3 +9,4 @@
SHA1 (patch-src_curve__server.cpp) = 7acd371d1e8ec6064d086c2dc503cdd0ec6c9a58
SHA1 (patch-src_platform.hpp.in) = 767370bd997310cddeb7ee1f759bec1a638974e0
SHA1 (patch-src_tcp__address.cpp) = ad1c1ec9b724c3bd7f0fae15c296e0ec33b4267a
+SHA1 (patch-src_thread.cpp) = e5ffcc1f9e80c255d6dee244ab6966ae6f25d279
cvs diff: Diffing patches
Index: patches/patch-src_thread.cpp
===================================================================
RCS file: patches/patch-src_thread.cpp
diff -N patches/patch-src_thread.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_thread.cpp 7 Feb 2016 23:45:07 -0000
@@ -0,0 +1,31 @@
+$NetBSD$
+
+--- src/thread.cpp.orig 2015-06-15 09:43:08.000000000 +0000
++++ src/thread.cpp
+@@ -114,26 +114,6 @@ void zmq::thread_t::stop ()
+
+ void zmq::thread_t::setSchedulingParameters(int priority_, int schedulingPolicy_)
+ {
+-#if !defined ZMQ_HAVE_ZOS
+- int policy = 0;
+- struct sched_param param;
+-
+- int rc = pthread_getschedparam(descriptor, &policy, ¶m);
+- posix_assert (rc);
+-
+- if(priority_ != -1)
+- {
+- param.sched_priority = priority_;
+- }
+-
+- if(schedulingPolicy_ != -1)
+- {
+- policy = schedulingPolicy_;
+- }
+-
+- rc = pthread_setschedparam(descriptor, policy, ¶m);
+- posix_assert (rc);
+-#endif
+ }
+
+ #endif
>Release-Note:
>Audit-Trail:
From: Yuval Langer <yuval.langer@gmail.com>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: pkg/50780: net/zeromq broken on NetBSD current
Date: Sun, 3 Apr 2016 00:40:01 +0300
I have received the following possible solution to this problem from ryoshu:
$NetBSD$
--- src/thread.cpp.orig 2015-06-15 09:43:08.000000000 +0000
+++ src/thread.cpp
@@ -114,26 +114,28 @@ void zmq::thread_t::stop ()
void zmq::thread_t::setSchedulingParameters(int priority_, int
schedulingPolicy_)
{
#if !defined ZMQ_HAVE_ZOS
int policy = 0;
struct sched_param param;
int rc = pthread_getschedparam(descriptor, &policy, ¶m);
posix_assert (rc);
if(priority_ != -1)
{
param.sched_priority = priority_;
}
if(schedulingPolicy_ != -1)
{
policy = schedulingPolicy_;
}
+ if(policy == SCHED_OTHER) return;
+
rc = pthread_setschedparam(descriptor, policy, ¶m);
posix_assert (rc);
#endif
}
#endif
From: Yuval Langer <yuval.langer@gmail.com>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: pkg/50780: net/zeromq broken on NetBSD current
Date: Sun, 3 Apr 2016 01:10:57 +0300
A new solution from riastradh@netbsd.org and kamil@netbsd.org (ryoshu):
$NetBSD$
--- src/thread.cpp.orig 2015-06-15 09:43:08.000000000 +0000
+++ src/thread.cpp
@@ -114,26 +114,28 @@ void zmq::thread_t::stop ()
void zmq::thread_t::setSchedulingParameters(int priority_, int
schedulingPolicy_)
{
#if !defined ZMQ_HAVE_ZOS
int policy = 0;
struct sched_param param;
int rc = pthread_getschedparam(descriptor, &policy, ¶m);
posix_assert (rc);
if(priority_ != -1)
{
param.sched_priority = priority_;
}
if(schedulingPolicy_ != -1)
{
policy = schedulingPolicy_;
}
+ if(policy == SCHED_OTHER) priority = PRI_NONE;
+
rc = pthread_setschedparam(descriptor, policy, ¶m);
posix_assert (rc);
#endif
}
#endif
On 3 April 2016 at 00:40, Yuval Langer <yuval.langer@gmail.com> wrote:
> I have received the following possible solution to this problem from ryoshu:
>
> $NetBSD$
>
> --- src/thread.cpp.orig 2015-06-15 09:43:08.000000000 +0000
> +++ src/thread.cpp
> @@ -114,26 +114,28 @@ void zmq::thread_t::stop ()
>
> void zmq::thread_t::setSchedulingParameters(int priority_, int
> schedulingPolicy_)
> {
> #if !defined ZMQ_HAVE_ZOS
> int policy = 0;
> struct sched_param param;
>
> int rc = pthread_getschedparam(descriptor, &policy, ¶m);
> posix_assert (rc);
>
> if(priority_ != -1)
> {
> param.sched_priority = priority_;
> }
>
> if(schedulingPolicy_ != -1)
> {
> policy = schedulingPolicy_;
> }
>
> + if(policy == SCHED_OTHER) return;
> +
> rc = pthread_setschedparam(descriptor, policy, ¶m);
> posix_assert (rc);
> #endif
> }
>
> #endif
From: Yuval Langer <yuval.langer@gmail.com>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: pkg/50780: net/zeromq broken on NetBSD current
Date: Sun, 3 Apr 2016 02:00:08 +0300
I made a mistake in the previous message.
$NetBSD$
--- src/thread.cpp.orig 2015-06-15 09:43:08.000000000 +0000
+++ src/thread.cpp
@@ -77,6 +77,7 @@ void zmq::thread_t::setSchedulingParamet
#else
#include <signal.h>
+#include <sys/param.h>
extern "C"
{
@@ -131,6 +132,8 @@ void zmq::thread_t::setSchedulingParamet
policy = schedulingPolicy_;
}
+ if(policy == SCHED_OTHER) param.sched_priority = PRI_NONE;
+
rc = pthread_setschedparam(descriptor, policy, ¶m);
posix_assert (rc);
#endif
An alternative solution is to use `-1` instead of `PRI_NONE` and to
not `#include <sys/param.h>`.
$NetBSD$
--- src/thread.cpp.orig 2015-06-15 09:43:08.000000000 +0000
+++ src/thread.cpp
@@ -131,6 +131,8 @@ void zmq::thread_t::setSchedulingParamet
policy = schedulingPolicy_;
}
+ if(policy == SCHED_OTHER) param.sched_priority = -1;
+
rc = pthread_setschedparam(descriptor, policy, ¶m);
posix_assert (rc);
#endif
On 3 April 2016 at 01:10, Yuval Langer <yuval.langer@gmail.com> wrote:
> A new solution from riastradh@netbsd.org and kamil@netbsd.org (ryoshu):
>
>
> $NetBSD$
>
> --- src/thread.cpp.orig 2015-06-15 09:43:08.000000000 +0000
> +++ src/thread.cpp
> @@ -114,26 +114,28 @@ void zmq::thread_t::stop ()
>
> void zmq::thread_t::setSchedulingParameters(int priority_, int
> schedulingPolicy_)
> {
> #if !defined ZMQ_HAVE_ZOS
> int policy = 0;
> struct sched_param param;
>
> int rc = pthread_getschedparam(descriptor, &policy, ¶m);
> posix_assert (rc);
>
> if(priority_ != -1)
> {
> param.sched_priority = priority_;
> }
>
> if(schedulingPolicy_ != -1)
> {
> policy = schedulingPolicy_;
> }
>
> + if(policy == SCHED_OTHER) priority = PRI_NONE;
> +
> rc = pthread_setschedparam(descriptor, policy, ¶m);
> posix_assert (rc);
> #endif
> }
>
> #endif
>
> On 3 April 2016 at 00:40, Yuval Langer <yuval.langer@gmail.com> wrote:
>> I have received the following possible solution to this problem from ryoshu:
>>
>> $NetBSD$
>>
>> --- src/thread.cpp.orig 2015-06-15 09:43:08.000000000 +0000
>> +++ src/thread.cpp
>> @@ -114,26 +114,28 @@ void zmq::thread_t::stop ()
>>
>> void zmq::thread_t::setSchedulingParameters(int priority_, int
>> schedulingPolicy_)
>> {
>> #if !defined ZMQ_HAVE_ZOS
>> int policy = 0;
>> struct sched_param param;
>>
>> int rc = pthread_getschedparam(descriptor, &policy, ¶m);
>> posix_assert (rc);
>>
>> if(priority_ != -1)
>> {
>> param.sched_priority = priority_;
>> }
>>
>> if(schedulingPolicy_ != -1)
>> {
>> policy = schedulingPolicy_;
>> }
>>
>> + if(policy == SCHED_OTHER) return;
>> +
>> rc = pthread_setschedparam(descriptor, policy, ¶m);
>> posix_assert (rc);
>> #endif
>> }
>>
>> #endif
From: "Kamil Rytarowski" <kamil@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/50780 CVS commit: pkgsrc/net/zeromq
Date: Sun, 3 Apr 2016 00:01:30 +0000
Module Name: pkgsrc
Committed By: kamil
Date: Sun Apr 3 00:01:30 UTC 2016
Modified Files:
pkgsrc/net/zeromq: distinfo
Added Files:
pkgsrc/net/zeromq/patches: patch-src_thread.cpp
Log Message:
Add patch from Yuval Langer
Comment from the cherry-picked commit:
Defining thread priority for SCHED_OTHER is implementation defined.
Some platforms like NetBSD cannot reassign it as they are dynamic.
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_getschedparam.html>
Credit goes to kamil@netbsd.org and riastradh@netbsd.org for finding this
solution.
This should address PR pkg/50780 by Travis Paul
To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 pkgsrc/net/zeromq/distinfo
cvs rdiff -u -r0 -r1.1 pkgsrc/net/zeromq/patches/patch-src_thread.cpp
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Kamil Rytarowski <n54@gmx.com>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: pkg/50780: net/zeromq broken on NetBSD current
Date: Sun, 3 Apr 2016 02:04:48 +0200
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
T,P., Could you please validate whether the committed fix has solved
your issue?
Thank you in advance,
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQIcBAEBCAAGBQJXAF4fAAoJEEuzCOmwLnZsG9wP/jqnZ0pYl/0jCfdK+945K8NP
6F1S0DPKfsb55QkSQzCRL9cHdz3DSmhVsGVep/Ol+oI9r/3tjhCFIwEKy2rc07JC
jUNNFj+M43wZEGMJdtL9mkjtnCOoTfNd39ciIFTqwdutEdTrbITU+G+7b6hIsv40
pORW4hEaaQrfM7SMYoSupZDqjynkBpy+p7gD8Z33VLT8GexNPWTj7g2wxIFhlToB
jG1r596hTaTS8P2oZTj+PYNdplNIrmOCIhPIkO+YjeycfiJXidanM5tGNnHHCWJ1
2C9qR0is88nd6aDn+MpfemSFvetmCRts36T3cUpLj3eRZV6FQYHcI35i9bI2O4nt
ocwVUv0jTzNTAK50lTFAazjI1uAynzOglIftTqwZle+6nsUpsa+gkMusDYU51bnX
/CKrzMmNhbeMfmOtDYdnGASUUQYPhdsCTQAYrAOzp6f9DPBkGwL6NqUE6NdBnMRs
fv6JE7Stj0KsAbnAXcle+uCTDxe9J+ce1uyITBlLRrX6AfINPM3XXXeNe37m9ZnB
UJcF0hHSoqkzvPp1tLRmj5+bWJE+JuCj/WoQ8RzTJXPPpKSWrniKjKsbEHEXBEOk
+RVP7ZhVOCvJ3mXBOrR2L1zCrgzKWaVBdykvt+WM+e3mEVXpR1aCnr2XstuTTJE4
NjdHu4M20UmGw0kXhsb5
=Ifof
-----END PGP SIGNATURE-----
State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 04 Apr 2016 07:50:57 +0000
State-Changed-Why:
did the change fix it?
From: tr@vispaul.me
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: pkg/50780: net/zeromq broken on NetBSD current
Date: Mon, 04 Apr 2016 19:40:31 -0400
The committed fix is working locally for me. Feel free to close this
PR.
Thank you Kamil and Yuval
State-Changed-From-To: feedback->closed
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Tue, 05 Apr 2016 06:09:27 +0000
State-Changed-Why:
Confirmed fixed, thanks!
From: "Thomas Klausner" <wiz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/50780 CVS commit: pkgsrc/net/zeromq
Date: Tue, 5 Apr 2016 14:09:27 +0000
Module Name: pkgsrc
Committed By: wiz
Date: Tue Apr 5 14:09:26 UTC 2016
Modified Files:
pkgsrc/net/zeromq: Makefile
Log Message:
Bump PKGREVISION for patch fixing PR 50780.
To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 pkgsrc/net/zeromq/Makefile
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.