Re: [PATCH] scripts/kallsyms: Fix build failure by setting errno before calling getline()

From: James Clark
Date: Tue Jul 25 2023 - 04:56:21 EST




On 25/07/2023 01:41, Miguel Ojeda wrote:
> On Mon, Jul 24, 2023 at 3:18 PM James Clark <james.clark@xxxxxxx> wrote:
>>
>> This fixes the following build failure if scripts/kallsyms launches with
>> a non-zero errno value:
>
> The code change sounds good to me, but could you please describe the
> situation where you found the build failure?
>
> Cheers,
> Miguel

I assumed it was something to do with one of the wrappers I'm using but
didn't get to the bottom of it because I'm using quite a few.

But I just checked now and it's just bear [1] that causes the issue.
Maybe it sets errno before forking and that persists in the child
processes? Not 100% sure how it works. I did debug scripts/kallsyms and
errno was already set on the first line of main(), so it's not some
other library call in kallsyms that is setting it but not being checked.

The minimal reproducer for me looks like this:

bear -- make ARCH=arm64 LLVM=1 O=../build/

[1]: https://manpages.ubuntu.com/manpages/focal/en/man1/bear.1.html