After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 562385 - gnome-pty-helper goes to 100% cpu usage
gnome-pty-helper goes to 100% cpu usage
Status: RESOLVED FIXED
Product: vte
Classification: Core
Component: general
0.17.x
Other All
: Normal major
: ---
Assigned To: VTE Maintainers
VTE Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-11-26 22:08 UTC by Jasper Lievisse Adriaanse
Modified: 2008-11-27 23:57 UTC
See Also:
GNOME target: ---
GNOME version: 2.23/2.24


Attachments
possible fix (1.36 KB, patch)
2008-11-26 23:54 UTC, Christian Persch
none Details | Review
updated patch (2.35 KB, patch)
2008-11-27 00:07 UTC, Christian Persch
none Details | Review

Description Jasper Lievisse Adriaanse 2008-11-26 22:08:03 UTC
Please describe the problem:
on openbsd/amd64, and perhaps other 64-bit platforms too, running "gnome-terminal" will make "gnome-pty-helper" approach the 100% cpu usage. this happens within a matter of seconds. this is currently unconfirmed on openbsd/sparc64 or other 64-bit ports, but it doesn't manifest itself on openbsd/i386.

it has been an issue since at least two years now. there are some patches applied to the openbsd port of vte, which you can find here: http://www.openbsd.org/cgi-bin/cvsweb/ports/devel/vte/



Steps to reproduce:
1. start gnome-terminal on openbsd/amd64 (cpu-usage stays very low) 
2. now start another terminal, notice that this process seems to go to the background when started from a shell (the prompt comes back, whilst this doesn't happen with the first terinal).
3. watch cpu usage approach 100% directly after the second terminal was started.



Actual results:
  PID USERNAME PRI NICE  SIZE   RES STATE    WAIT      TIME    CPU COMMAND
20892 jasper    64    0  300K 1412K onproc/1 -         1:02 94.29% gnome-pty-helper


Expected results:
the gnome-pty-helper process doesn't go beserk :)

Does this happen every time?
yes.

Other information:
please note that this doesn't happen when there's only one gnome-terminal running. right after the second terminal is started the problem occurs.

kdump(1) reveals it is continuously retrying to read(2) from stdin without
need. read(2) returns EAGAIN:

>    [EAGAIN]      The file was marked for non-blocking I/O, and no data were
>                  ready to be read.

the bug in gnome-pty-helper is triggered by some input from gnome-terminal
(g-p-h communicates via STDIN/STDOUT with g-t) when g-p-h is spawned by
g-t.

i can upload the kdump(1) file if needed.
Comment 1 Christian Persch 2008-11-26 22:35:00 UTC
(In reply to comment #0)
> 2. now start another terminal, notice that this process seems to go to the
> background when started from a shell (the prompt comes back, whilst this
> doesn't happen with the first terinal).
That's normal. gnome-terminal uses a server process, the 2nd call just forwards the arguments to the factory and exits.

> please note that this doesn't happen when there's only one gnome-terminal
> running. right after the second terminal is started the problem occurs.

Does it also happen if you just open a new tab or window in the first gnome-terminal process?
Comment 2 Jasper Lievisse Adriaanse 2008-11-26 22:37:02 UTC
yes, it also happens when i open a tab in the first gnome-terminal process.
Comment 3 Jasper Lievisse Adriaanse 2008-11-26 22:41:40 UTC
(In reply to comment #2)
> yes, it also happens when i open a tab in the first gnome-terminal process.

same for opening a new window in the first gnome-terminal process btw.

Comment 4 Christian Persch 2008-11-26 23:54:18 UTC
Created attachment 123508 [details] [review]
possible fix

Just for reference , the code in question was introduced in bug 126554.

Do the CMSG_SPACE and CMSG_LEN macros exist on your platform? If so, this should fix the problem (and also be more correct).
Comment 5 Christian Persch 2008-11-27 00:07:03 UTC
Created attachment 123510 [details] [review]
updated patch

Seems these defines may not exist on some platforms; so define them if they're not there yet.
Comment 6 Jasper Lievisse Adriaanse 2008-11-27 17:40:31 UTC
thanks for this diff! it fixes the reported issue.

so this can be closed.
Comment 7 Christian Persch 2008-11-27 20:08:57 UTC
Great, thanks for the testing.

Behdad, Chris: does the patch look ok to you too?
Comment 8 Behdad Esfahbod 2008-11-27 20:13:45 UTC
I'm not following the details, but looks good, yes.
Comment 9 Christian Persch 2008-11-27 23:57:31 UTC
Committed to svn trunk:

        * gnome-pty-helper/gnome-pty-helper.c: (pass_fd), (pty_free),
        (main): Make sure data structures are correctly aligned and of the
        right size.