From: sundeep.kokkonda@gmail.com
To: <libc-help@sourceware.org>, <libc-help-info@sourceware.org>,
<libc-alpha@sourceware.org>, <libc-alpha-info@sourceware.org>
Subject: Suspected bug in mq_timedreceive
Date: Thu, 30 Jun 2022 12:07:26 +0530 [thread overview]
Message-ID: <000f01d88c4b$df941790$9ebc46b0$@gmail.com> (raw)
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.
next reply other threads:[~2022-06-30 6:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-30 6:37 sundeep.kokkonda [this message]
2022-06-30 11:10 ` Adhemerval Zanella
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='000f01d88c4b$df941790$9ebc46b0$@gmail.com' \
--to=sundeep.kokkonda@gmail.com \
--cc=libc-alpha-info@sourceware.org \
--cc=libc-alpha@sourceware.org \
--cc=libc-help-info@sourceware.org \
--cc=libc-help@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).