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 311855 - Race in vte leads to blocking of input.
Race in vte leads to blocking of input.
Status: RESOLVED FIXED
Product: vte
Classification: Core
Component: general
0.11.x
Other All
: High normal
: ---
Assigned To: Behdad Esfahbod
VTE Maintainers
Depends on:
Blocks:
 
 
Reported: 2005-07-28 12:15 UTC by Kalle Raiskila
Modified: 2006-07-10 19:15 UTC
See Also:
GNOME target: ---
GNOME version: 2.5/2.6


Attachments
Patch for the bug (1.50 KB, patch)
2005-08-25 09:04 UTC, Kalle Raiskila
committed Details | Review

Description Kalle Raiskila 2005-07-28 12:15:48 UTC
Please describe the problem:
When running the function vte_terminal_feed_child an race occurs which leads
to vte not placing a "watch" for the G_IO_OUT channel. This leads to Vte not
accepting input for the child process. (That is, Vte freezes)
( I wrote about this in bug nr 117945, but I'm not sure it was the same bug)

Steps to reproduce:
1. build an application with a vte terminal
2. run vte_terminal_feed_child()
3. run vte_terminal_feed_child()



Actual results:
The 2. call (and any subsequent calls) to vte_terminal_feed_child() don't do
anything

Expected results:
Input should be fed to the child process

Does this happen every time?
On some platforms yes, on others no.

Other information:
The problem seems to lie in src/vte.c file with the
terminal->pvt->pty_output_source variable. In the function
_vte_terminal_connect_pty_write() the pty_output_source-variable
is assigned the return value of the function g_io_add_watch_full().
The race happens when the callback registered by g_io_add_watch_full()
gets called before g_io_add_watch_full() returns. 
The callback function (eventually) calls  _vte_terminal_disconnect_pty_write(),
which shall set terminal->pvt->pty_output_source to VTE_INVALID_SOURCE.
But since terminal->pvt->pty_output_source isn't set to the return value of
g_io_add_watch_full(), it doesn't get cleared, and hence, will remain with the
value eventually returned by  g_io_add_watch_full(). This value then prevents 
_vte_terminal_connect_pty_write() from ever setting an other GIO-watch, and thus
vte will not send any data to the child.

Protecting terminal->pvt->pty_output_source with a mutex seems to make the race
dissappear (but it's hardly an optimal solution?)
Comment 1 Michele Baldessari 2005-07-29 08:59:33 UTC
Thanks a lot for this detailed report Kalle,

marking HIGH and NEW.
Comment 2 Kalle Raiskila 2005-08-25 09:04:11 UTC
Created attachment 51322 [details] [review]
Patch for the bug

I've tested this ad-hoc patch extensivly with vte-0.11.13.
I also make a quick test with vte-0.11.15, and it seems to work
(and solve the problem, too).
Comment 3 Behdad Esfahbod 2006-07-10 19:15:54 UTC
Thanks!

2006-07-10  Behdad Esfahbod  <behdad@gnome.org>

        Bug 311855 – Race in vte leads to blocking of input.
        Patch from Kalle Raiskila

        * src/vte-private.h:
        * src/vte.c (_vte_terminal_connect_pty_write),
        (_vte_terminal_disconnect_pty_write), (vte_terminal_init):
        Use a mutex for pty_output_source.