NetBSD Problem Report #57213
From bruno@clisp.org Sat Feb 4 01:37:53 2023
Return-Path: <bruno@clisp.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_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 1DBA71A9239
for <gnats-bugs@gnats.NetBSD.org>; Sat, 4 Feb 2023 01:37:53 +0000 (UTC)
Message-Id: <5496327.neEdIFSld5@nimes>
Date: Sat, 04 Feb 2023 02:34:46 +0100
From: Bruno Haible <bruno@clisp.org>
Reply-To: bruno@clisp.org
To: gnats-bugs@netbsd.org
Subject: sigprocmask return value wrong when libpthread is in use
>Number: 57213
>Category: lib
>Synopsis: The return value of sigprocmask is not standards compliant
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Feb 04 01:40:00 +0000 2023
>Originator: bruno@clisp.org
>Release: NetBSD 9.0
>Organization:
GNU
>Environment:
System: NetBSD netbsd9.bruno.haible.de 9.0 NetBSD 9.0 (GENERIC) #0: Fri Feb 14 00:06:28 UTC 2020 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
When a program that is linked with libpthread uses the sigprocmask function,
its return value can be wrong.
See https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_sigmask.html
section "RETURN VALUE".
>How-To-Repeat:
Compile this program
==================== foo.c ================
#include <errno.h>
#include <signal.h>
#include <stdio.h>
int main ()
{
sigset_t set;
int ret;
sigemptyset (&set);
sigaddset (&set, SIGINT);
ret = sigprocmask (1729, &set, NULL);
if (ret == 0)
printf ("sigprocmask succeeded!\n");
else
printf ("sigprocmask -> %d, errno=%d\n", ret, errno);
ret = pthread_sigmask (1729, &set, NULL);
if (ret == 0)
printf ("pthread_sigmask succeeded!\n");
else
printf ("pthread_sigmask -> %d\n", ret);
return 0;
}
=============================================
$ gcc -Wall foo.c -lpthread
$ ./a.out
Expected output:
sigprocmask -> -1, errno=22
pthread_sigmask -> 22
Actual output:
sigprocmask -> 22, errno=22
pthread_sigmask -> 22
>Fix:
(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-2023
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.