All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sam James <sam@gentoo.org>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>,
	 Nicolas Schier <nicolas@fjasle.eu>,
	 linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fixdep: handle short reads in read_file
Date: Sat, 07 Sep 2024 14:26:11 +0100	[thread overview]
Message-ID: <87seubioi4.fsf@gentoo.org> (raw)
In-Reply-To: <87y143ixdb.fsf@gentoo.org> (Sam James's message of "Sat, 07 Sep 2024 11:14:40 +0100")

Sam James <sam@gentoo.org> writes:

> Masahiro Yamada <masahiroy@kernel.org> writes:
>
>> On Sat, Sep 7, 2024 at 12:29 AM Sam James <sam@gentoo.org> wrote:
>
> Hi Masahiro,
>
>>>
>>> 50% or so of kernel builds within our package manager fail for me with
>>> 'fixdep: read: success' because read(), for some reason - possibly ptrace,
>>> only read a short amount, not the full size.
>>>
>>> Unfortunately, this didn't trigger a -Wunused-result warning because
>>> we _are_ checking the return value, but with a bad comparison (it's completely
>>> fine for read() to not read the whole file in one gulp).
>>>
>>> Fixes: 01b5cbe7012fb1eeffc5c143865569835bcd405e
>>
>>
>> Fixes: 01b5cbe7012f ("fixdep: use malloc() and read() to load dep_file
>> to buffer")
>>
>
> Ah, thanks. I'll fix that and send v2 depending on how we decide to move
> forward wrt below.
>
>>
>> I guess, another approach would be to use fread() instead of read().
>>
>> Does the attached diff fix the issue too?
>>
>>
>
> Unfortunately no. It failed for me in the same way as before :(
>
> The man page mentions:
>> On  success, fread() and fwrite() return the number of items read or
>> written. This number equals the number of bytes transferred only when size is 1.  
>
> so I guess it suffers from the same pitfall. I checked POSIX & ISO C as well
> which says:
>> If a partial element is read, its value is unspecified.
> and
>> The fread() function shall return the number of elements successfully
>> read, which shall be less than nitems only if an error or end-of-file
>> is encountered, or size is zero.
>
> The error reference is kind of mysterious there though.
>
> It kind of looks like fread *should* work. I'll send this mail and then
> think about it a bit later and ask around to see if I'm missing
> something obvious?

OK, others disagree with my reading of fread and think it is ambiguous.

With your patch, I was able to get failures albeit possibly less
frequently. I'm trying my patch again in a loop now.

>
>> [...]
>
> thanks,
> sam

  reply	other threads:[~2024-09-07 13:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-06 15:29 [PATCH] fixdep: handle short reads in read_file Sam James
2024-09-07  2:02 ` Masahiro Yamada
2024-09-07 10:14   ` Sam James
2024-09-07 13:26     ` Sam James [this message]
2024-09-07 23:48       ` Masahiro Yamada
2024-09-08  8:20         ` Sam James

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=87seubioi4.fsf@gentoo.org \
    --to=sam@gentoo.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nicolas@fjasle.eu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.