Bug 488652 - vim should not fork() after initializing windows
Summary: vim should not fork() after initializing windows
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: vim
Version: 11
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Karsten Hopp
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-03-05 02:48 UTC by Lennart Poettering
Modified: 2010-06-28 11:24 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-06-28 11:24:06 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Lennart Poettering 2009-03-05 02:48:21 UTC
gvim is seriously broken. On startup it initializes GTK, sets up the main window and then forks. This is really really evil.

Almost no existing modern library is written in a way that this would work correctly, and Gtk certainly isn't. After a fork() the child process only retains a single thread and all mutexes/semaphores/... are left in an undefined state. In theory one could reinitialize the mutexes after the fork or lock them during the fork by using pthread_atfork() and set up all necessary background threads again, in reality nobody does this because it is really hard to get right. 

fork()ing is only OK if you quickly call some form of exec() without calling any non-libc functions before. Or if you do it in a pristine process. But setting things up and then forking is really not OK. 

In the Gtk case the mutex locked by GDK_THREADS_ENTER is at least one mutex that would need to be reinitialized after the fork but isn't. 

Also a lot lof libraries cannot really cope with the PID changing underneath them.

The particular case where this brokeness in vim became apparent is when libcanberra-gtk-module is loaded into gvim via GTK_MODULES: when the window is popped up first an event sound is played which causes the module to spawn an audio IO thread. Then, the fork happens and another sound is triggered due to some reason. However in the child process the audio IO thread is gone and hence the triggering of the sound will block for a response of the thread who will never respond because it doesn't exist. I am now modifying libcanberra to refuse all calls after a fork() -- but really, gvim needs to be fixed to not do evil stuff like this.

A possible way to fix this is either forking earlier (before the gtk initialization) or reexecuting yourself after the fork.

Comment 1 Bug Zapper 2009-06-09 11:53:18 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 11 development cycle.
Changing version to '11'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 2 Richard Z. 2009-10-27 11:36:23 UTC
thanks for looking at it, I have been bitten by this gvim problem in a fully updated Fedora 10 as well.

In my own programs I do a lot of evil forking, it gives functionality not achievable with threading. It is one of the oldest and simplest syscalls and libraries should have defined a way of dealing with it.

Anyway, freezing the complete desktop just because a sound event does not work like expected is aksing for trouble - quite surprised it did not strike earlier.

Comment 3 Bug Zapper 2010-04-27 13:06:35 UTC
This message is a reminder that Fedora 11 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 11.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '11'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 11's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 11 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 4 Bug Zapper 2010-06-28 11:24:06 UTC
Fedora 11 changed to end-of-life (EOL) status on 2010-06-25. Fedora 11 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.