konsolePart/TerminalInterface: startProgram crashes when called after returning to event-loop

Peter Rockai (mornfall) mornfall at danill.sk
Tue Jun 8 00:50:34 BST 2004


I have been trying to embed konsolepart in my application. While i can work 
around the other issues with this part (see my other post, 
"ExtTerminalInterface + KProcess extension for KDE 3.4/4.0"), there is one i 
don't really understand.

The TerminalInterface provides a startProgram method, which is supposed to 
start a new child process in a KProcess (TEPty really, but this is a KProcess 
subclass). However, when the konsolePart is constructed, it sets up a 
immediate singleShot timer, which starts a shell in it, if no other program 
was started in the meantime. This, in itself, would be relatively acceptable, 
even while not really desirable.

The other problem is, that upon execution of this program, konsolePart 
connects its slot konsolePart::sessionDestroyed to the TESession's (which is 
wrapping up the TEPty and a terminal emulator class) signal destroyed (). 
This signal is emitted when the running child process is terminated or 
TESession is destroyed by other means. This would be also ok. The problem is 
in the sessionDestroyed slot and the startProgram method interaction.
This is what TESession does:
1017   if ( se ) delete se;
1018   se = new TESession(te, program, args, "xterm", parentWidget->winId());
and this is what sessionDestroyed does:
263   delete this;

As you can see, i hope, this is really unintuitive and IMO undesirable 
behaviour. What happens is, when startProgram is called for the second time, 
or is called from a slot in my application, when an "se" object already 
exists, it will trigger massive amounts of invalid memory access and crash 
with SIGSEGV in the result.

Now, i'm not really sure about the solution. I locally commented out the 
"delete this" call in konsolePart::sessionDestroyed, which is what i deem as 
rather sane. If you have other suggestions, i'd be glad to hear them.


PS: This issue is present both in branch and head versions.

More information about the kde-core-devel mailing list