Clear konsole command-line before directory change
AbandonedPublic

Authored by cullmann on Jan 1 2018, 2:28 PM.

Details

Summary

When changing tabs anything that exists in the command line gets executed.
That can be very dangerous. Dolphin clears the command line. I copied/pasted that code.

Test Plan

Open 2 files residing in different directories in kate
Activate konsole plugin.
In konsole type 'ls /tmp' (not ENTER)
Change tab.

-> ls /tmp should not execute

Diff Detail

Repository
R40 Kate
Branch
arcpatch-D9590
Lint
No Linters Available
Unit
No Unit Test Coverage
michaelh requested review of this revision.Jan 1 2018, 2:28 PM
michaelh created this revision.
michaelh edited the test plan for this revision. (Show Details)Jan 1 2018, 2:40 PM

As I'm not allowed to leave this comment empty I might as well state that I am completely new to *ALL* technologies involved here i.e. C++, Qt, git, phabricator etc
(I can read though).

dhaumann accepted this revision.EditedJan 1 2018, 7:17 PM
dhaumann added a subscriber: dhaumann.

First, thanks for this patch - it makes a lot of sense. And congratulations you worked through most of the KDE infrastructure (accounts, phabricator, arc, git, ...).

I think this patch is good.

Strictly speaking, you are copying GPL code into a a file that uses LGPL. Usually this requires an agreement of the initial author (Peter Penz, 2012, see https://github.com/KDE/dolphin/commit/14d5a32475ef646e51f6750a80f216020b648039).

Then again, we are simply using 2 lines, which is in my opinion not enough to require relicensing to LGPL.

I guess you do not have git commit access?

This revision is now accepted and ready to land.Jan 1 2018, 7:17 PM

Yippieh: Smiling from ear to ear here. Thanks for your reply!

Up to a few minutes ago I didn't even think about Licensing, sorry. The heap of things I have to learn just grew a little. Now there are 2 Questions:

  1. How did you find out who is responsible for that dolphin code?
  2. What would have been the proper way to ask the author for his agreement?

I guess you do not have git commit access?

I guess not. (Not even quite sure what that is.). I fetched all the code with kdesrc-build, which was an excellent way to get started BTW

I also guess this touches my third Question: What next?

I'll give some hints of what I did:

  • you gave me the hint to src/kde/applications/dolphin/src/panels/terminal/terminalpanel.cpp@167
  • I checked out the dolphin git repo
  • went to the terminal folder, and typed: git annotate terminalplane.cpp <enter>, and went to line 167
  • This tells me Peter Penz, but it's not yet sure he was really the initial author.
  • then I entered: git log -S "kill(processId, SIGINT);"
  • essentially, this command shows me ALL commits with changed lines that contain the string "kill(processId, SIGINT);"
  • It shows 2 commits, both from Peter Penz.
  • I copied the sha 14d5a32475ef646e51f6750a80f216020b648039 and entered in the github search, which gives 3 code matches.

With that, I have a final link to the file, showing the commit on the web that added the change. :-)

There may be better ways to find this out, but I once learned the git log -S "text" trick and it works for me. You may want to see if you find better ways, though.

Now that we know it was Peter Penz who added this, we usually should add him as reviewer here in Phabricator. But he stopped KDE development many years ago. The only way to reach him would be to send a direct mail, CCing a public mailing list. However, I think this is overkill for these three lines, and Peter also entered himself here: https://cgit.kde.org/kde-dev-scripts.git/tree/relicensecheck.pl#n344 - stating that he in general is also fine with LGPL variants (see more details here: https://techbase.kde.org/Projects/KDE_Relicensing).

Which leaves us with what to do next: Someone with commit access (git push to KDE servers will work, it will not currently work for you) will push this to the server, closing this review request.

What I now did is:

  • copy the link behind "Download Raw Diff" in the top right
  • in the terminal, I cd'ed into kate.git, and typed: wget https://phabricator.kde.org/file/data/dvyfeaphmpg6urfgoip2/PHID-FILE-zw34xdqxdltejw3t56wf/D9590.diff
  • I applied the patch, typing:

dh:~/kde/kf5/src/kde/applications/kate> patch -p1 < D9590.diff

patching file addons/konsole/kateconsole.cpp
Hunk #1 succeeded at 21 (offset -1 lines).
Hunk #2 succeeded at 250 (offset -10 lines).

  • git diff shows me that the changes look good
  • then I type: git add addons/konsole/kateconsole.cpp
  • git status now lists that I added the changes to staging
  • Now I locally commit with: `git commit --author="Michael Heidelbach <email@address.abc>"

Unfortunately, this is how far I get, since your email address is invisible to me. So either I commit in my name (which would not be the correct author) - or I wait until you tell me (e.g. to dhaumann@kde.org).

Hope that helps so far :-)

Btw, I just posed on kde-core-devel to find out how to get email addressed on phabricator: https://marc.info/?l=kde-core-devel&m=151492773414285&w=2

michaelh added a comment.EditedJan 2 2018, 9:40 PM

Hope that helps so far :-)

Of course it does! Thank you very much.
I did not intend to hide my email. A quick scan over my profile settings revealed nothing so I leave that for later. And my email is ...
ottwolt@gmail.com

This revision was automatically updated to reflect the committed changes.
sars added a subscriber: sars.Jan 11 2018, 12:06 PM

Hmm... This patch causes my terminal to just flash up and then disappear immediately...

It's the same for me - I'll revert for now, since this seems to entirely break Kate's terminal toolview.

Reverted, see https://commits.kde.org/kate/6303cc4a0788d84190db74951fc2db639456a8bc

Now why does this work in Dolphin, but not in Kate? :-)

With KDevelop:
make clean
make
make install

Debug current launch => works as expected
Execute current launch => panel does not show, clicking buttons activates them but respective panel does not show
Debug current launch again => does not work: same as Execute current launch

What's happening here?

$ git checkout origin/Applications/17.12
In KDevelop:
clean
build
install
run

In Kate:
Trying to show panels ends in this

Messed setup or deeper problem?
Qt 5.10.0-2.2

I have the same issue. I saw things like this before, not sure whether Kate really picks up the correct plugins. Maybe it's messed up with the plugins from the stable system.

lsof -p $(pgrep kate) | grep KF5
lsof: WARNING: can't stat() tracefs file system /sys/kernel/debug/tracing
      Output information may be incomplete.
kate    18144 super  mem       REG                8,5  2063488 35127770 /home/super/bin/kde-latest/lib64/plugins/kf5/org.kde.kwindowsystem.platforms/KF5WindowSystemX11Plugin.so
kate    18144 super  mem       REG                8,1    43776   571052 /usr/lib64/libKF5Pty.so.5.41.0
kate    18144 super  mem       REG                8,5  4964064 35148716 /home/super/bin/kde-latest/lib64/libKF5ThreadWeaver.so.5.42.0
kate    18144 super  mem       REG                8,5  3956288 35148599 /home/super/bin/kde-latest/lib64/libKF5ItemModels.so.5.42.0
kate    18144 super  mem       REG                8,5  7407264 35149228 /home/super/bin/kde-latest/lib64/libKF5NewStuffCore.so.5.42.0
kate    18144 super  mem       REG                8,5  7917104 35149227 /home/super/bin/kde-latest/lib64/libKF5NewStuff.so.5.42.0
kate    18144 super  mem       REG                8,1    39616   564756 /usr/lib64/libKF5Style.so.5.41.0
kate    18144 super  mem       REG                8,1  1025584   571625 /usr/lib64/libKF5Solid.so.5.41.0
kate    18144 super  mem       REG                8,1   304528   556567 /usr/lib64/libKF5Bookmarks.so.5.41.0
kate    18144 super  mem       REG                8,1   763528   566373 /usr/lib64/libKF5WaylandClient.so.5.41.0
kate    18144 super  mem       REG                8,1   358392   573890 /usr/lib64/libKF5Notifications.so.5.41.0
kate    18144 super  mem       REG                8,1   900176   524077 /usr/lib64/libKF5KIOFileWidgets.so.5.41.0
kate    18144 super  mem       REG                8,5  2784232 35149210 /home/super/bin/kde-latest/lib64/libKF5GlobalAccel.so.5.42.0
kate    18144 super  mem       REG                8,5 13489120 35149150 /home/super/bin/kde-latest/lib64/libKF5Attica.so.5.42.0
kate    18144 super  mem       REG                8,5  2675472 35149207 /home/super/bin/kde-latest/lib64/libKF5SonnetCore.so.5.42.0
kate    18144 super  mem       REG                8,5  4125096 35149200 /home/super/bin/kde-latest/lib64/libKF5ItemViews.so.5.42.0
kate    18144 super  mem       REG                8,5  3286264 35149197 /home/super/bin/kde-latest/lib64/libKF5Archive.so.5.42.0
kate    18144 super  mem       REG                8,5  6550168 35148703 /home/super/bin/kde-latest/lib64/libKF5SyntaxHighlighting.so.5.42.0
kate    18144 super  mem       REG                8,5  5771968 35149221 /home/super/bin/kde-latest/lib64/libKF5Activities.so.5.42.0
kate    18144 super  mem       REG                8,5  7990272 35149175 /home/super/bin/kde-latest/lib64/libKF5CoreAddons.so.5.42.0
kate    18144 super  mem       REG                8,5  4851816 35149174 /home/super/bin/kde-latest/lib64/libKF5WindowSystem.so.5.42.0
kate    18144 super  mem       REG                8,5   693376 35149201 /home/super/bin/kde-latest/lib64/libKF5Crash.so.5.42.0
kate    18144 super  mem       REG                8,5  3086496 35140121 /home/super/bin/kde-latest/lib64/libKF5DBusAddons.so.5.42.0
kate    18144 super  mem       REG                8,5  3334976 35149194 /home/super/bin/kde-latest/lib64/libKF5GuiAddons.so.5.42.0
kate    18144 super  mem       REG                8,5  2759752 35149195 /home/super/bin/kde-latest/lib64/libKF5Auth.so.5.42.0
kate    18144 super  mem       REG                8,5  3958984 35149172 /home/super/bin/kde-latest/lib64/libKF5ConfigCore.so.5.42.0
kate    18144 super  mem       REG                8,5  2475808 35149173 /home/super/bin/kde-latest/lib64/libKF5ConfigGui.so.5.42.0
kate    18144 super  mem       REG                8,5  5275136 35149196 /home/super/bin/kde-latest/lib64/libKF5Codecs.so.5.42.0
kate    18144 super  mem       REG                8,5 23186976 35127701 /home/super/bin/kde-latest/lib64/libKF5WidgetsAddons.so.5.42.0
kate    18144 super  mem       REG                8,5  2934848 35149193 /home/super/bin/kde-latest/lib64/libKF5I18n.so.5.42.0
kate    18144 super  mem       REG                8,5  5128264 35149199 /home/super/bin/kde-latest/lib64/libKF5ConfigWidgets.so.5.42.0
kate    18144 super  mem       REG                8,5  3234600 35149205 /home/super/bin/kde-latest/lib64/libKF5IconThemes.so.5.42.0
kate    18144 super  mem       REG                8,5  2905360 35149208 /home/super/bin/kde-latest/lib64/libKF5SonnetUi.so.5.42.0
kate    18144 super  mem       REG                8,5  3291720 35149206 /home/super/bin/kde-latest/lib64/libKF5Completion.so.5.42.0
kate    18144 super  mem       REG                8,5 11148752 35149202 /home/super/bin/kde-latest/lib64/libKF5Service.so.5.42.0
kate    18144 super  mem       REG                8,5  3692216 35149209 /home/super/bin/kde-latest/lib64/libKF5TextWidgets.so.5.42.0
kate    18144 super  mem       REG                8,5 13932632 35149213 /home/super/bin/kde-latest/lib64/libKF5XmlGui.so.5.42.0
kate    18144 super  mem       REG                8,5  3316336 35149204 /home/super/bin/kde-latest/lib64/libKF5JobWidgets.so.5.42.0
kate    18144 super  mem       REG                8,5 22769504 35127740 /home/super/bin/kde-latest/lib64/libKF5KIOCore.so.5.42.0
kate    18144 super  mem       REG                8,5 17146016 35127755 /home/super/bin/kde-latest/lib64/libKF5KIOWidgets.so.5.42.0
kate    18144 super  mem       REG                8,5  6850664 35149226 /home/super/bin/kde-latest/lib64/libKF5Parts.so.5.42.0
kate    18144 super  mem       REG                8,5 55554112 35127791 /home/super/bin/kde-latest/lib64/libKF5TextEditor.so.5.42.0

@michaelh The button issue was introduced in KWidgetAddons and is meanwhile fixed: https://phabricator.kde.org/D9884

Unfortunately, this bug was released in KDE Frameworks 5.42.

So in this review request, we can focus on why Konsole crashed for me and @sars .

After update to KF 5.42
In KDevelop:
First run => OK
Consecutive runs =>

 cd /tmp/test
^@

Warning: Program '/bin/bash' crashed.

First run in debugger => OK
Consecutive runs => bash crash
BUT:
Setting a breakpoint at equivalent of line 252 => runs always OK, even if breakpoint is disabled after first hit.

dhaumann reopened this revision.Jan 26 2018, 6:28 PM

Reopen on request.

This revision is now accepted and ready to land.Jan 26 2018, 6:28 PM
michaelh updated this revision to Diff 26017.Jan 26 2018, 8:23 PM

Desynchronized sending input to terminal

Please remove the accepted flag

anthonyfieroni added inline comments.
addons/konsole/kateconsole.cpp
250

Remove these lines with simple

Qtimer::singleShot(0, &Qtimer::timeout, this, [this, text]() {
michaelh updated this revision to Diff 26021.Jan 26 2018, 11:02 PM

Simplify Timer statement
Silence compiler warning 'misleading indentation'

michaelh marked an inline comment as done.Jan 26 2018, 11:03 PM
dhaumann requested changes to this revision.Jan 28 2018, 11:27 AM

Currently, the code doesn't tell why an asynchronous send via a lambda-function/timer is needed. Could you add on this?

addons/konsole/kateconsole.cpp
250

Could you add a comment on why this needs to be a singleShot timer? It's not obvious to me right now.

This revision now requires changes to proceed.Jan 28 2018, 11:27 AM

Another comment: Could you remove trailing spaces in your changes lines?

Btw, I just tested: If I remove slotSync() in KateConsole::loadConsoleIfNeeded() then it works. So this indeed is a timing issue we face. The ^C in this case then immediately tells the embedded konsole to quit, which is wrong of course. I have not debugged further, but understanding what's going on would certainly help to get the correct patch.

@hindenburg Would it make sense to extend the TerminalInterface somehow to clear input data of current line or send this ^C as done by Dolphin and proposed in this patch?

Back in 2012 Konsole implemented this in 693cecbae73896f03a1c47f4c41a0fa30759d917 - Konsole keeps a list of valid programs that accept Ctrl+C

Having this in TerminalInterface seems reasonable

cullmann commandeered this revision.May 8 2019, 5:44 PM
cullmann added a reviewer: michaelh.
cullmann added a subscriber: cullmann.

We consider this fixed with D20974.
If that is still lacking stuff, please reopen the new revision, thanks!

Restricted Application added a subscriber: kwrite-devel. · View Herald TranscriptMay 8 2019, 5:44 PM
cullmann abandoned this revision.May 8 2019, 5:44 PM