From: Petr Vorel <pvorel@suse.cz>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] lib/tst_test.c: Fix tst_brk() handling
Date: Fri, 4 Apr 2025 14:55:17 +0200 [thread overview]
Message-ID: <20250404125517.GA527835@pevik> (raw)
In-Reply-To: <Z-_K0zj30GOhxYS8@yuki.lan>
> Hi!
> > diff --git a/lib/tst_test.c b/lib/tst_test.c
> > index c6395a5eb..6b1100b09 100644
> > --- a/lib/tst_test.c
> > +++ b/lib/tst_test.c
> > @@ -407,7 +407,8 @@ void tst_vbrk_(const char *file, const int lineno, int ttype, const char *fmt,
> > * current process.
> > */
> > if (TTYPE_RESULT(ttype) == TBROK) {
> > - tst_atomic_inc(&results->abort_flag);
> > + if (results)
> > + tst_atomic_inc(&results->abort_flag);
> > /*
> > * If TBROK was called from one of the child processes we kill
> And it's a bit more complex we also need to make sure to exit properly
> when tst_brk() was called before the library was initialized, so we also
+1
> need:
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index 758e62823..d19908d94 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -386,6 +386,14 @@ void tst_vbrk_(const char *file, const int lineno, int ttype, const char *fmt,
> va_list va)
> {
> print_result(file, lineno, ttype, fmt, va);
> +
> + /*
> + * If tst_brk() is called from some of the C helpers even before the
> + * library was initialized, just exit.
> + */
> + if (!lib_pid)
> + exit(TTYPE_RESULT(ttype));
Interesting, I never noticed lib_pid :). It's assigned in tst_run_tcases() -
library gets initialized there. As that's the very first call in main(), this
really applies for helpers in testcases/lib/ which define TST_NO_DEFAULT_MAIN.
I suppose this is the part of the fix for core dumped helpers.
> +
> update_results(TTYPE_RESULT(ttype));
> /*
> @@ -415,7 +423,7 @@ void tst_vbrk_(const char *file, const int lineno, int ttype, const char *fmt,
> * the main test process. That in turn triggers the code that
> * kills leftover children once the main test process did exit.
> */
> - if (tst_getpid() != main_pid) {
> + if (main_pid && tst_getpid() != main_pid) {
> tst_res(TINFO, "Child process reported TBROK killing the test");
> kill(main_pid, SIGKILL);
> }
> I will send v2 later on.
+1
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2025-04-04 12:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-03 11:30 [LTP] [PATCH] lib/tst_test.c: Fix tst_brk() handling Cyril Hrubis
2025-04-03 12:36 ` Petr Vorel
2025-04-03 14:12 ` Cyril Hrubis
2025-04-04 12:04 ` Cyril Hrubis
2025-04-04 12:55 ` Petr Vorel [this message]
2025-04-04 12:58 ` Jan Stancek via ltp
2025-04-04 14:00 ` Cyril Hrubis
2025-04-04 13:18 ` Petr Vorel
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=20250404125517.GA527835@pevik \
--to=pvorel@suse.cz \
--cc=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/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.