[patch v1] fgets: more tests
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Tue Aug 13 16:41:50 GMT 2024
On 13/08/24 13:26, Andrew Pinski wrote:
> On Tue, Aug 13, 2024 at 5:38 AM Adhemerval Zanella Netto
> <adhemerval.zanella@linaro.org> wrote:
>>
>>
>>
>> On 13/08/24 01:12, DJ Delorie wrote:
>>> Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> writes:
>>>> I has failed on Linaro CI [1]. To get the test output result, check the
>>>> tests.log.0.xz file, it contains all the failed tests outputs:
>>>>
>>>> FAIL: stdio-common/tst-fgets2
>>>> original exit status 127
>>>>
>>>> So it seems to be a crash on the test.
>>>
>>> The test logs disagree:
>>>
>>> In file included from ../include/bits/stdio2.h:1,
>>> from ../libio/stdio.h:970,
>>> from ../include/stdio.h:14,
>>> from tst-fgets2.c:21:
>>> In function ‘fgets’,
>>> inlined from ‘do_test’ at tst-fgets2.c:248:9:
>>> ../libio/bits/stdio2.h:313:12: error: argument 1 is null but the corresponding size argument 2 value is 100 [-Werror=nonnull]
>>> 313 | return __fgets_alias (__s, __n, __stream);
>>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>> In file included from ../include/sys/cdefs.h:10,
>>> from ../include/features.h:511,
>>> from ../bits/floatn-common.h:23,
>>> from ../bits/floatn.h:52,
>>> from ../include/stdio.h:7,
>>> from tst-fgets2.c:21:
>>> ../libio/bits/stdio2.h: In function ‘do_test’:
>>> ../libio/bits/stdio2-decl.h:96:26: note: in a call to function ‘__fgets_alias’ declared with attribute ‘access (write_only, 1, 2)’
>>> 96 | extern char *__REDIRECT (__fgets_alias,
>>> | ^~~~~~~~~~~~~
>>> ../misc/sys/cdefs.h:410:41: note: in definition of macro ‘__REDIRECT’
>>> 410 | # define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
>>> | ^~~~
>>>
>>> However, that call is explicitly wrapped in macros that should ignore
>>> that error:
>>>
>>> DIAG_PUSH_NEEDS_COMMENT;
>>> /* We're intentionally passing an invalid size here. */
>>> DIAG_IGNORE_NEEDS_COMMENT (7, "-Wnonnull");
>>> str = fgets (NULL, 100, f);
>>> DIAG_POP_NEEDS_COMMENT;
>>>
>>> That silenced it locally. I wonder why it doesn't silence it in your CI
>>> chain? Am I misunderstanding how these DIAG_* work?
>>
>> It seems something has changed on gcc 12, and the Linaro bots uses the
>> system compiler which is gcc 11. On gcc 11 it seems that the _Pragma (...)
>> only works for static inline if you add them *before* function declaration,
>> where on gcc 12 it works on function instantiation.
>>
>> This following patch fixes the issues on older gcc:
>
> This seems not related to the version of GCC but rather if
> _FORTIFY_SOURCE is defined or not.
Off course it is due _FORTIFY_SOURCE, otherwise there is not static inline wrapper
for fgets. But the test uses exactly the same flags, and the _Pragma (...) to
suppress the warning only works at function instantiation with gcc 12.
More information about the Libc-alpha
mailing list