From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: sundeep.kokkonda@gmail.com
Cc: libc-help@sourceware.org, libc-help-info@sourceware.org,
libc-alpha@sourceware.org, libc-alpha-info@sourceware.org
Subject: Re: Suspected bug in mq_timedreceive
Date: Thu, 30 Jun 2022 08:10:54 -0300 [thread overview]
Message-ID: <EF4F6D95-CB93-4692-9944-262418851DB3@linaro.org> (raw)
In-Reply-To: <000f01d88c4b$df941790$9ebc46b0$@gmail.com>
> On 30 Jun 2022, at 03:37, sundeep.kokkonda--- via Libc-help <libc-help@sourceware.org> wrote:
>
> 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;
Yeah, this is incorrect. I will open a bug an fix it on all affected releases.
At least for 2.36 the time64 code path is only used if the target date can not
be fit in 32-bit time_t.
prev parent reply other threads:[~2022-06-30 11:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-30 6:37 sundeep.kokkonda
2022-06-30 11:10 ` Adhemerval Zanella [this message]
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=EF4F6D95-CB93-4692-9944-262418851DB3@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=libc-alpha-info@sourceware.org \
--cc=libc-alpha@sourceware.org \
--cc=libc-help-info@sourceware.org \
--cc=libc-help@sourceware.org \
--cc=sundeep.kokkonda@gmail.com \
/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).