Closed kbroulik closed 7 years ago
I consider it foremost an issue (there are multiple others) with how krunner uses libqalculate. The calculator runner should use the libqalculate functions the stops slow RAM-eating calculations after a specified amount of time.
Firstly: I agree with @hanna-kn that krunner should terminate libqalculate calls after a timeout.
Yet, Note:
This memory consuming bug occurs even with simple, everyday calculations!
2^0.333333333
The memory issue triggers only when using at least 9 digits after the comma.
Such calculations are not extraordinary and no user would expect this to freeze his system.
@hanna-kn
Can you confirm that the latest version of libqalculate has an issue with 2^0.333333333
?
PS: I guess i had to install libxml2-dev (debian) so autogen is happy. I tried to build but then it fails because at the configure stage it forgot to warn be about the cln dependency.
@hanna-kn Question: Is there a switch that krunner could use such that normal double precision calculations are performed when calculations are going to take (too) long?
If exact or 'try exact' mode is used 2^0.333333333 is calculated as (2^333333333)^(1/1E9), which for obvious reasons is slow (although the result is returned after less then four seconds on my computer). In approximate mode (perhaps most appropriate for krunner) the result is returned practically instantaneously.
I have now fixed slow calculation of exponentiations in exact and "try exact" modes. When exact calculation fails the exponent is now no longer split up in numerator and denominator if the numerator is larger than 10 000 (or smaller than -10 000).
@hanna-kn Just tested the change. Works great. Thank you very much!
edit: @hanna-kn I forgot the ./
in ./qalc facepalm. Thats why it showed the old behaviour.
@numsim1415 No, that is not expected. With the change, no matter how many 3's I enter the result is returned instantaneously.
Qalculate! will now realize that 2^2^2^2^2^2^2 (= 2^(2^(2^(2^(2^(2^2)))) = 2^(2^2,0035299E19728)) is ridiculous and not try to calculate it.
When I try to calculate the following
it starts to eat all RAM until the application is killed. (Using libqalculate 0.9.7-9.1)
Downstream bug report: https://bugs.kde.org/show_bug.cgi?id=277011