From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by sourceware.org (Postfix) with ESMTPS id 6AACC3846472; Thu, 30 Jun 2022 06:37:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6AACC3846472 Received: by mail-pl1-x62b.google.com with SMTP id d5so16140639plo.12; Wed, 29 Jun 2022 23:37:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :thread-index:content-language; bh=QIOiCbRuakujWm5uJFQh3K6mAefbp1bZJwMbsaGARNo=; b=g9gyiB4+ZZ831IAslh7GC1JgZ8SxeBdyiMHyEQ2mB/AtilP46v+CaTzVS8Tsln/+zI id2p3qhlUVVF4CqMTKv3kczBRE0NHE8bWaUAHkuXXo1ETwCdMCzRgXZ4E78HLxtKCmq9 ddNsjaC707Rg1vMZwfkz00l9oRPZ/y2dzt4B5Tzp7adV1FDAiDx68KvGqY5kibl7fqNw Ia8J2HP5rC13Q8gh9QW2fk34if2nh4jAwoyqbsj7b0WVTdSwWQG+xq0NkK2KMVgb7Vi2 jnZSJOHsv6sqshaSzbcvBZ4MAcPoPJlOp2UYjL2PWjGtFfgLIrL3Bskp5laVRK7AZXKc SoFA== X-Gm-Message-State: AJIora9wqp+hgnEZNeGmPiaZOJf6IvwJDbeVY9wpKgm5MneLkDJlQ7mD YmAOEndBrOqXTkw/owiedOxlOPWpkcA= X-Google-Smtp-Source: AGRyM1u0fwzIFSe3E/+p9zXxLs/s9R9RBJp9bvTGhqS6zrNmHmqZxLK9JSWgkDcT0hQFDD8RbZrFDg== X-Received: by 2002:a17:90b:4f44:b0:1ed:64a1:9769 with SMTP id pj4-20020a17090b4f4400b001ed64a19769mr10680501pjb.136.1656571051727; Wed, 29 Jun 2022 23:37:31 -0700 (PDT) Received: from LPTBFTI009 ([49.205.112.83]) by smtp.gmail.com with ESMTPSA id d4-20020a170902e14400b0016a46ee3b49sm12409279pla.236.2022.06.29.23.37.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Jun 2022 23:37:30 -0700 (PDT) From: sundeep.kokkonda@gmail.com X-Google-Original-From: To: , , , Subject: Suspected bug in mq_timedreceive Date: Thu, 30 Jun 2022 12:07:26 +0530 Message-ID: <000f01d88c4b$df941790$9ebc46b0$@gmail.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdiMS4h/+GNjRL9GQxCOOJNV0X/cfA== Content-Language: en-in X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jun 2022 06:37:35 -0000 Hello, The mq_timedreceive code in glibc-2.33/sysdeps/unix/sysv/linux/mq_timedreceive.c does this: ssize_t _mq_timedreceive_time64 (mqd_t mqdes, char *_restrict msg_ptr, size_t msg_len, unsigned int *__restrict msg_prio, const struct _timespec64 *_restrict abs_timeout) { #ifndef __NR_mq_timedreceive_time64 #define __NR_mq_timedreceive_time64 __NR_mq_timedreceive #endif int ret = SYSCALL_CANCEL (mq_timedreceive_time64, mqdes, msg_ptr, msg_len, msg_prio, abs_timeout); #ifndef __ASSUME_TIME64_SYSCALLS if (ret == 0 || errno != ENOSYS) return ret; struct timespec ts32; if (abs_timeout != NULL) { if (! in_time_t_range (abs_timeout->tv_sec)) { __set_errno (EOVERFLOW); return -1; } ts32 = valid_timespec64_to_timespec (*abs_timeout); } ret = SYSCALL_CANCEL (mq_timedreceive, mqdes, msg_ptr, msg_len, msg_prio, abs_timeout != NULL ? &ts32 : NULL); #endif return ret; } This test is wrong: if (ret == 0 || errno != ENOSYS) return ret; That test would be correct if mq_timedreceive returned 0 on success, as is the case for mq_timedsend. However, mq_timedreceive actually returns the number of bytes read, so the correct test is: If (ret >= 0 || errno != ENOSYS) return ret; @community: Can you comment on this, whether it is a bug or implemented intentionally for any specific reason? I checked the latest glibc-2.35 sources as well, the check for ret==0 is still the same. Thanks, Sundeep K.