($INBOX_DIR/description missing)
 help / color / mirror / Atom feed
From: "Yang Xu (徐扬)" <Yang.Xu@mediatek.com>
To: "richard.purdie@linuxfoundation.org"
	<richard.purdie@linuxfoundation.org>,
	"bitbake-devel@lists.openembedded.org"
	<bitbake-devel@lists.openembedded.org>
Subject: Re: [bitbake-devel] [PATCH] bitbake-worker: Fix silent hang issue caused by unexpected stdout content
Date: Thu, 22 Feb 2024 06:08:21 +0000	[thread overview]
Message-ID: <aca5f3feb93c42bb1178a4622d1423aa4c2d2b06.camel@mediatek.com> (raw)
In-Reply-To: <dc3e8b3949f3208910cd41da56cc8f1c84bcfb81.camel@linuxfoundation.org>

[-- Attachment #1: Type: text/plain, Size: 2592 bytes --]

Sorry, I noticed this patch has not been merged. Is there any further work that I need to complete?
Or is bitbake planning to swtich to the solution that does not use stdin/stdout directly.

Thank you

On Sun, 2024-02-04 at 23:01 +0000, Richard Purdie wrote:

> This patch addresses an issue in bitbake-worker where stdout,

> reserved for status reporting, is improperly accessed by child processes.

>

> The problem occurs during the execution of parseRecipe,

> which calls anonymous functions. If these functions use print-like operations,

> they can inadvertently output data to stdout. This unexpected data can cause

> the runqueue to hang silently, if the stdout buffer is flushed

> before exec_task is executed.

>

> To prevent this, the patch redirects stdout to /dev/null and ensures it is

> flushed prior to the execution of exec_task.

>

> Signed-off-by: Yang Xu <yang.xu@mediatek.com>

> ---

>  bin/bitbake-worker | 12 +++++++++---

>  1 file changed, 9 insertions(+), 3 deletions(-)

>

> diff --git a/bin/bitbake-worker b/bin/bitbake-worker

> index eba9c562..0ba18572 100755

> --- a/bin/bitbake-worker

> +++ b/bin/bitbake-worker

> @@ -237,9 +237,11 @@ def fork_off_task(cfg, data, databuilder, workerdata, extraconfigdata, runtask):

>              # Let SIGHUP exit as SIGTERM

>              signal.signal(signal.SIGHUP, sigterm_handler)

>

> -            # No stdin

> -            newsi = os.open(os.devnull, os.O_RDWR)

> -            os.dup2(newsi, sys.stdin.fileno())

> +            # No stdin & stdout

> +            # stdout is used as a status report channel and must not be used by child processes.

> +            dumbio = os.open(os.devnull, os.O_RDWR)

> +            os.dup2(dumbio, sys.stdin.fileno())

> +            os.dup2(dumbio, sys.stdout.fileno())

>

>              if umask:

>                  os.umask(umask)

> @@ -305,6 +307,10 @@ def fork_off_task(cfg, data, databuilder, workerdata, extraconfigdata, runtask):

>                  if not quieterrors:

>                      logger.critical(traceback.format_exc())

>                  os._exit(1)

> +

> +            sys.stdout.flush()

> +            sys.stderr.flush()

> +

>              try:

>                  if dry_run:

>                      return 0


This looks like a good catch.


I'm wondering if we should change the code to use a different file

descriptor for the communication and leave stdout/stderr alone

instead...


Cheers,


Richard




[-- Attachment #2: Type: text/html, Size: 4606 bytes --]

      reply	other threads:[~2024-02-22  6:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-02  9:36 [PATCH] bitbake-worker: Fix silent hang issue caused by unexpected stdout content yang.xu
2024-02-04 23:01 ` [bitbake-devel] " Richard Purdie
2024-02-22  6:08   ` Yang Xu (徐扬) [this message]

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=aca5f3feb93c42bb1178a4622d1423aa4c2d2b06.camel@mediatek.com \
    --to=yang.xu@mediatek.com \
    --cc=bitbake-devel@lists.openembedded.org \
    --cc=richard.purdie@linuxfoundation.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).