Re: [PATCH] scripts/kallsyms: Fix build failure by setting errno before calling getline()
From: James Clark
Date: Tue Jul 25 2023 - 07:04:08 EST
On 25/07/2023 11:33, Miguel Ojeda wrote:
> On Tue, Jul 25, 2023 at 10:55 AM James Clark <james.clark@xxxxxxx> wrote:
>>
>> 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.
>
> I think this is https://github.com/rizsotto/Bear/issues/469: bear
> preloads a library which was setting it to non-zero.
>
> Now, even if bear was breaking a guarantee C programs have (`errno`
> for the initial thread at program startup is meant to be 0 according
> to the C standard), it is still a good idea to set `errno` to zero
> here in case something else happens to change `errno` within
> `kallsyms` in the future.
>
> With the repro and the `bear` link issue added:
>
> Reviewed-by: Miguel Ojeda <ojeda@xxxxxxxxxx>
>
> Cheers,
> Miguel
Oh yeah nice find, that's the issue. I added it and sent a v2.
Thanks
James