New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 870485 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
Last visit > 30 days ago
Closed: Aug 6
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 3
Type: Bug



Sign in to add a comment

Clean up the "frecon <defunct>" zombie process

Project Member Reported by djkurtz@chromium.org, Aug 2

Issue description

Chrome OS Version: R70-10931.0.0
Chrome OS Platform: any

Steps To Reproduce:
(1) Boot test image
(1) ps aux | grep frecon

Expected Result:
One live frecon process.

Actual Result:
root       253  0.7  0.1  18960  4940 ?        Ss   16:43   0:00 frecon --daemon --clear 0xfffefefe --frame-interval 25 --dev-mode --enable-osc --enable-vts --pre-create-vts --image-hires /usr/share/chromeos-assets/images_200_percent/boot_splash_frame01.png --image-hires /usr/share/chromeos-assets/images_200_percent/boot_splash_frame02.png --image-hires /usr/share/chromeos-assets/images_200_percent/boot_splash_frame03.png --image-hires /usr/share/chromeos-assets/images_200_percent/boot_splash_frame04.png --image-hires /usr/share/chromeos-assets/images_200_percent/boot_splash_frame05.png --image-hires /usr/share/chromeos-assets/images_200_percent/boot_splash_frame06.png --image-hires /usr/share/chromeos-assets/images_200_percent/boot_splash_frame07.png --image-hires /usr/share/chromeos-assets/images_200_percent/boot_splash_frame08.png --image-hires /usr/share/chromeos-assets/images_200_percent/boot_splash_frame09.png --image-hires /usr/share/chromeos-assets/images_200_percent/boot_splash_frame10.png --image-hires /usr/share/chromeos-assets/images_200_percent/boot_splash_frame11.png --image-hires /usr/share/chromeos-assets/images_200_percent/boot_splash_frame12.png --image-hires /usr/share/chromeos-assets/images_200_percent/boot_splash_frame13.png --image /usr/share/chromeos-assets/images_100_percent/boot_splash_frame01.png --image /usr/share/chromeos-assets/images_100_percent/boot_splash_frame02.png --image /usr/share/chromeos-assets/images_100_percent/boot_splash_frame03.png --image /usr/share/chromeos-assets/images_100_percent/boot_splash_frame04.png --image /usr/share/chromeos-assets/images_100_percent/boot_splash_frame05.png --image /usr/share/chromeos-assets/images_100_percent/boot_splash_frame06.png --image /usr/share/chromeos-assets/images_100_percent/boot_splash_frame07.png --image /usr/share/chromeos-assets/images_100_percent/boot_splash_frame08.png --image /usr/share/chromeos-assets/images_100_percent/boot_splash_frame09.png --image /usr/share/chromeos-assets/images_100_percent/boot_splash_frame10.png --image /usr/share/chromeos-assets/images_100_percent/boot_splash_frame11.png --image /usr/share/chromeos-assets/images_100_percent/boot_splash_frame12.png --image /usr/share/chromeos-assets/images_100_percent/boot_splash_frame13.png
root       262  0.0  0.0      0     0 ?        Zs   16:43   0:00 [frecon] <defunct>



How frequently does this problem reproduce? (Always, sometimes, hard to
reproduce?)
Always?

This is not new.  From issue 793537#2 (Dec 16 2017) I see a "[frecon] <defunct>".
It is also not critical, but something we should probably clean up.
 
A little debugging shows that the zombie process is the process that was forked in shl_pty_open() for a non-interactive (--enable-vt1 is not set) TERM_SPLASH_TERMINAL.

Since TERM_SPLASH_TERMINAL is non-interactive, it doesn't have an interactive_cmd_line (terminal->exec == NULL), which means the forked child process doesn't execve(), but rather enters the sleep() loop in term_run_child():
https://cs.corp.google.com/chromeos_public/src/platform/frecon/term.c?q=term_run_child&g=0&l=68

Soon after entering its infinite sleep, the process receives SIGHUP when its controlling terminal is closed.  This terminates the sleep - and the process, leaving behind a zombie.  The frecon parent process never does a waitpid() on its terminal children, and hence the zombie is never reaped.
seems like an easy fix would be to just do signal(SIGCHLD, SIG_IGN) in the frecon parent
Owner: djkurtz@chromium.org
Status: Started (was: Available)
https://chromium-review.googlesource.com/c/chromiumos/platform/frecon/+/1162924 frecon: Don't leave zombies behind when children are killed
Project Member

Comment 4 by bugdroid1@chromium.org, Aug 5

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/frecon/+/c6036a87a1914ea95caf47a9c1b6a5766502bdb9

commit c6036a87a1914ea95caf47a9c1b6a5766502bdb9
Author: Daniel Kurtz <djkurtz@chromium.org>
Date: Sun Aug 05 06:46:37 2018

frecon: Don't leave zombies behind when children are killed

Frecon creates child processes for terminals using fork().
For interactive terminals, these forked processes use fork()/execve(),
for non-interactive terminals, the forked process stays in an infinite
sleep.

If the non-interactive terminal's infinite-sleeping child process receives
SIGHUP it will die, but since frecon isn't paying attention, the process
will remain a zombie.

We can use sigaction to set the SA_NOCLDWAIT flag on the SIG_DFL handler
to keep such children from becoming zombies.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>

BUG= chromium:870485 
TEST=stop ui
  pkill frecon
  frecon --daemon
  ps -ef | grep frecon
 => No "[frecon] <defunct>"

Change-Id: I41d19d05e7b18ed1e154f4023006ef95954abaa8
Reviewed-on: https://chromium-review.googlesource.com/1162924
Commit-Ready: Daniel Kurtz <djkurtz@chromium.org>
Tested-by: Daniel Kurtz <djkurtz@chromium.org>
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>

[modify] https://crrev.com/c6036a87a1914ea95caf47a9c1b6a5766502bdb9/main.c

Status: Verified (was: Started)
Project Member

Comment 6 by bugdroid1@chromium.org, Sep 21

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/frecon/+/fbd668b02214a81e304732e1703ae9909271e04e

commit fbd668b02214a81e304732e1703ae9909271e04e
Author: Rajat Jain <rajatja@chromium.org>
Date: Fri Sep 21 07:51:15 2018

Revert "frecon: Don't leave zombies behind when children are killed"

This reverts commit c6036a87a1914ea95caf47a9c1b6a5766502bdb9.

Reason for revert: For unknown reasons this CL causes a blank out of 2-3 seconds on multiple platforms. I tried alternate ways to do the cleanup this CL was doing (https://buganizer.corp.google.com/issues/115927088#comment13) but none works. Lets revert this cleanup CL to avoid a functional regression.

Original change's description:
> frecon: Don't leave zombies behind when children are killed
>
> Frecon creates child processes for terminals using fork().
> For interactive terminals, these forked processes use fork()/execve(),
> for non-interactive terminals, the forked process stays in an infinite
> sleep.
>
> If the non-interactive terminal's infinite-sleeping child process receives
> SIGHUP it will die, but since frecon isn't paying attention, the process
> will remain a zombie.
>
> We can use sigaction to set the SA_NOCLDWAIT flag on the SIG_DFL handler
> to keep such children from becoming zombies.
>
> Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
>
> BUG= chromium:870485 
> TEST=stop ui
>   pkill frecon
>   frecon --daemon
>   ps -ef | grep frecon
>  => No "[frecon] <defunct>"
>
> Change-Id: I41d19d05e7b18ed1e154f4023006ef95954abaa8
> Reviewed-on: https://chromium-review.googlesource.com/1162924
> Commit-Ready: Daniel Kurtz <djkurtz@chromium.org>
> Tested-by: Daniel Kurtz <djkurtz@chromium.org>
> Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
> Reviewed-by: Mike Frysinger <vapier@chromium.org>

Bug:  chromium:870485 , b:115927088
Change-Id: Ie839709f7941d673d1013a7516c3b08c04f1594e
Reviewed-on: https://chromium-review.googlesource.com/1237331
Commit-Ready: Rajat Jain <rajatja@chromium.org>
Tested-by: Rajat Jain <rajatja@chromium.org>
Reviewed-by: Rajat Jain <rajatja@chromium.org>
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>

[modify] https://crrev.com/fbd668b02214a81e304732e1703ae9909271e04e/main.c

Project Member

Comment 7 by bugdroid1@chromium.org, Sep 21

Labels: merge-merged-release-R70-11021.B
The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/frecon/+/7f3e574c5de80ad5196616e3a89a42fa607de95c

commit 7f3e574c5de80ad5196616e3a89a42fa607de95c
Author: Rajat Jain <rajatja@chromium.org>
Date: Fri Sep 21 23:42:27 2018

Revert "frecon: Don't leave zombies behind when children are killed"

This reverts commit c6036a87a1914ea95caf47a9c1b6a5766502bdb9.

Reason for revert: For unknown reasons this CL causes a blank out of 2-3 seconds on multiple platforms. I tried alternate ways to do the cleanup this CL was doing (https://buganizer.corp.google.com/issues/115927088#comment13) but none works. Lets revert this cleanup CL to avoid a functional regression.

Original change's description:
> frecon: Don't leave zombies behind when children are killed
>
> Frecon creates child processes for terminals using fork().
> For interactive terminals, these forked processes use fork()/execve(),
> for non-interactive terminals, the forked process stays in an infinite
> sleep.
>
> If the non-interactive terminal's infinite-sleeping child process receives
> SIGHUP it will die, but since frecon isn't paying attention, the process
> will remain a zombie.
>
> We can use sigaction to set the SA_NOCLDWAIT flag on the SIG_DFL handler
> to keep such children from becoming zombies.
>
> Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
>
> BUG= chromium:870485 
> TEST=stop ui
>   pkill frecon
>   frecon --daemon
>   ps -ef | grep frecon
>  => No "[frecon] <defunct>"
>
> Change-Id: I41d19d05e7b18ed1e154f4023006ef95954abaa8
> Reviewed-on: https://chromium-review.googlesource.com/1162924
> Commit-Ready: Daniel Kurtz <djkurtz@chromium.org>
> Tested-by: Daniel Kurtz <djkurtz@chromium.org>
> Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
> Reviewed-by: Mike Frysinger <vapier@chromium.org>

Bug:  chromium:870485 , b:115927088
Change-Id: Ie839709f7941d673d1013a7516c3b08c04f1594e
Reviewed-on: https://chromium-review.googlesource.com/1237331
Commit-Ready: Rajat Jain <rajatja@chromium.org>
Tested-by: Rajat Jain <rajatja@chromium.org>
Reviewed-by: Rajat Jain <rajatja@chromium.org>
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
(cherry picked from commit fbd668b02214a81e304732e1703ae9909271e04e)
Reviewed-on: https://chromium-review.googlesource.com/1238848
Commit-Queue: Rajat Jain <rajatja@chromium.org>
Trybot-Ready: Rajat Jain <rajatja@chromium.org>

[modify] https://crrev.com/7f3e574c5de80ad5196616e3a89a42fa607de95c/main.c

Sign in to add a comment