Page MenuHomeFreeBSD

libc: Add a rudimentary test for quick_exit(3).
ClosedPublic

Authored by des on Sep 22 2023, 11:20 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 11, 1:40 AM
Unknown Object (File)
Wed, Oct 23, 3:52 PM
Unknown Object (File)
Wed, Oct 23, 3:52 PM
Unknown Object (File)
Wed, Oct 23, 3:52 PM
Unknown Object (File)
Wed, Oct 23, 3:51 PM
Unknown Object (File)
Wed, Oct 23, 3:51 PM
Unknown Object (File)
Wed, Oct 23, 3:48 PM
Unknown Object (File)
Sep 23 2024, 10:19 AM
Subscribers

Details

Summary

Sponsored by: Klara, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

check at_quick_exit() return value

kib added inline comments.
lib/libc/tests/stdlib/quick_exit_test.c
73

What guarantees that buf is nul-terminated?

des marked an inline comment as done.Sep 26 2023, 7:13 PM
des added inline comments.
lib/libc/tests/stdlib/quick_exit_test.c
73

It doesn't matter, the comparison will fail before overrunning.

des marked an inline comment as done.Sep 26 2023, 7:13 PM
lib/libc/tests/stdlib/quick_exit_test.c
73

It fails and results in false test failure. If buf is not terminated by nul, strcmp() can return false despite initialized part of the buf containing the right chars.

In fact, it worked for you because stack is zero-initialized and buf is large enough to not reuse anything in stack space.

des marked an inline comment as done.Sep 26 2023, 7:25 PM
des added inline comments.
lib/libc/tests/stdlib/quick_exit_test.c
73

You missed the fact that buf is initialized to all-zeroes on line 51. The only way it can end up being unterminated is if the child produces something else than what we expected, in which case the resultant test failure is very much the intended outcome.

des marked an inline comment as done.Sep 26 2023, 7:25 PM
kib added inline comments.
lib/libc/tests/stdlib/quick_exit_test.c
73

Indeed, sorry.

This revision is now accepted and ready to land.Sep 26 2023, 7:30 PM
des marked an inline comment as done.Sep 26 2023, 8:05 PM
This revision was automatically updated to reflect the committed changes.