Bug 277011 - krunner calculator should check feasibility of calculations
Summary: krunner calculator should check feasibility of calculations
Status: RESOLVED FIXED
Alias: None
Product: krunner
Classification: Plasma
Component: calculator (other bugs)
Version First Reported In: 5.0
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-03 15:12 UTC by ronny-kdebug
Modified: 2017-03-28 08:28 UTC (History)
8 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 5.8.7
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ronny-kdebug 2011-07-03 15:12:09 UTC
Version:           unspecified (using KDE 4.6.4) 
OS:                Linux

If calculations that are typed into krunner that are to complex, it starts to calculate and (in my case) uses full system ressources, so that the whole system stops responding. Even if i would configurate it this way, that it has restricted ressources, such a calculation doesn't make sense.

Reproducible: Always

Steps to Reproduce:
type into krunner: =2^2^2^2^2^2
Warning, do not try it on a productive system.

Actual Results:  
top shows a CPU usage of 200%, after a while swapping starts and makes system unrespondable.

Expected Results:  
matlab shows "inf" after a while
bc shows "Runtime error (func=(main), adr=23): exponent too large in raise"

i would consider this as a better result.
Comment 1 Anton Rasmussen 2012-06-11 12:02:09 UTC
I see similar behavior on KDE 4.8.3. In my experience it is only the power function that is problematic. For example: 
(20.1)^(1.3333333) gives high cpu+mem+wait, and it gets worse the more digits in the exponent.
(20.1)*(1.3333333) no problem

Strangely enough (pi)^(1.333333) gives no problem.
Comment 2 Anton Rasmussen 2012-06-11 12:04:02 UTC
Futher info: Krunner process keeps eating memory after deleting the offending digits.
Comment 3 Jesse TeKrony 2013-08-19 20:52:40 UTC
This is a major stability issue that is still occurring. When trying to calculate 2^137438953472, I didn't get an answer, so I assumed that number was way too large, closed krunner, and went on with my business.
A few moments later I noticed that my memory usage plasmoid was indicating that almost all of the 8 Gigabytes of memory was being used, so I opened my system monitor and found that krunner was using 100% CPU and almost all my memory.

Luckily, krunner crashed before it could cause my computer to freeze.

There really needs to be some sanity checks like (I assume that) KCalc does. If someone could, please at least mark this as confirmed for future reference to other people. XD
Comment 4 Vishesh Handa 2015-01-20 23:38:05 UTC
Confirmed on Plasma5.
Comment 5 Kai Uwe Broulik 2016-02-06 18:41:40 UTC
Doesn't do that for me, I just get "Infinity" as a result but it doesn't eat up CPU
Comment 6 Erik Quaeghebeur 2017-01-11 10:48:57 UTC
(In reply to Vishesh Handa from comment #4)
> Confirmed on Plasma5.
The problem is still here for 5.26.0 and plasma 5.8.5. This is a nasty bug, because it also appears on quite innocuous-seeming calculations, which then requires krunner to be killed, which is bothersome, as all applications started through krunner are then also killed. (I don't understand why applications launched in krunner become sub-processes; that seems like a bad idea; I'll see if a bug about that exists.)

(In reply to Kai Uwe Broulik from comment #5)
> Doesn't do that for me, I just get "Infinity" as a result but it doesn't eat
> up CPU
Hmm, when I type 2^2^2^2... I get, while typing, 1, 4, 16,... until at some point one core is hogged and my memory consumption starts to increase, and I have to kill krunner. If this doesn't happen for you, the backend must be different, perhaps?
Comment 7 Kai Uwe Broulik 2017-01-11 10:53:26 UTC
Probably depends on whether you have Qalculate or not.
I just entered "=2^2^2^2^2..." and now krunner is eating all RAM.
Comment 8 Erik Quaeghebeur 2017-01-11 11:02:00 UTC
(In reply to Kai Uwe Broulik from comment #7)
> Probably depends on whether you have Qalculate or not.
> I just entered "=2^2^2^2^2..." and now krunner is eating all RAM.

To be clear, you now get the issue as well because you have qalculate installed (as I do)? If that is the case, then this is probably a qalculate bug.
Comment 9 Kai Uwe Broulik 2017-01-11 11:36:35 UTC
Reported to libqalculate https://github.com/Qalculate/libqalculate/issues/16
Comment 10 Kai Uwe Broulik 2017-03-27 16:58:35 UTC
Git commit df7f1ed1eb7df7e3c039dc19db4893ca01b3327f by Kai Uwe Broulik.
Committed on 27/03/2017 at 16:57.
Pushed by broulik into branch 'master'.

[Calculator Runner] Use "approximate" approximation mode

The runner calculator isn't entitled for being a scientifically correct calculator.
This keeps seemingly innocent calculations such as "2^0.333333333" from eating all RAM until it crashes.
A hint is added to the result if it is only an approximation.
FIXED-IN: 5.10.0

Differential Revision: https://phabricator.kde.org/D4290

M  +7    -3    runners/calculator/calculatorrunner.cpp
M  +1    -1    runners/calculator/calculatorrunner.h
M  +9    -1    runners/calculator/qalculate_engine.cpp
M  +1    -1    runners/calculator/qalculate_engine.h

https://commits.kde.org/plasma-workspace/df7f1ed1eb7df7e3c039dc19db4893ca01b3327f
Comment 11 Kai Uwe Broulik 2017-03-28 08:28:46 UTC
Git commit 34b74d7b5dac9dd458a960e392954ac6c30df3d2 by Kai Uwe Broulik.
Committed on 28/03/2017 at 08:26.
Pushed by broulik into branch 'Plasma/5.8'.

[Calculator Runner] Use "approximate" approximation mode

The runner calculator isn't entitled for being a scientifically correct calculator.
This keeps seemingly innocent calculations such as "2^0.333333333" from eating all RAM until it crashes.
A hint is added to the result if it is only an approximation.
FIXED-IN: 5.8.7
CCMAIL: kde-i18n-doc@kde.org

Differential Revision: https://phabricator.kde.org/D4290

(cherry picked from commit df7f1ed1eb7df7e3c039dc19db4893ca01b3327f)

M  +7    -3    runners/calculator/calculatorrunner.cpp
M  +1    -1    runners/calculator/calculatorrunner.h
M  +9    -1    runners/calculator/qalculate_engine.cpp
M  +1    -1    runners/calculator/qalculate_engine.h

https://commits.kde.org/plasma-workspace/34b74d7b5dac9dd458a960e392954ac6c30df3d2