Bug 468084 - Calculator memory leak
Summary: Calculator memory leak
Status: RESOLVED FIXED
Alias: None
Product: krunner
Classification: Plasma
Component: calculator (show other bugs)
Version: 5.27.3
Platform: Manjaro Linux
: NOR major
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-02 16:47 UTC by Yeshi
Modified: 2023-04-08 16:01 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.27.5
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yeshi 2023-04-02 16:47:44 UTC
STEPS TO REPRODUCE
1. Open krunner
2. paste the following: 9^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€^€
3. Enter an additional "€"
4. Watch as krunner keeps allocating memory until plasma crashes

SOFTWARE/OS VERSIONS
Kernel: 6.2.8-1-MANJARO
KDE Plasma Version: 5.27.3
KDE Frameworks Version: 5.104.0
Qt Version: 5.15.8
Comment 1 Fushan Wen 2023-04-03 12:22:39 UTC
Please report the bug to libqalculate
Comment 2 Yeshi 2023-04-05 17:53:25 UTC
(In reply to Fushan Wen from comment #1)
> Please report the bug to libqalculate

I believe a timeout after a few seconds would go a long way here.
Perhaps even setting a memory limit could work.

Both of these solutions should be better than having plasmashell restart.
Comment 3 Yeshi 2023-04-05 17:54:21 UTC
(In reply to Yeshi from comment #2)
> (In reply to Fushan Wen from comment #1)
> > Please report the bug to libqalculate
> 
> I believe a timeout after a few seconds would go a long way here.
> Perhaps even setting a memory limit could work.
> 
> Both of these solutions should be better than having plasmashell restart.

Forgot to mention, I have reported this bug to libqalculate.
Comment 4 Bug Janitor Service 2023-04-06 17:54:03 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2799
Comment 5 Fushan Wen 2023-04-08 07:40:04 UTC
Git commit 3f3bea079bb55ec70ce248d1238cd0e7e38e5261 by Fushan Wen.
Committed on 08/04/2023 at 07:17.
Pushed by fusionfuture into branch 'Plasma/5.27'.

runners/calculator: set timeout to prevent allocating huge memory

This is not exactly a memory leak. The extreme expression simply
requires huge amounts of memory to calculate.

The calculator runner is problematic since it does not specify
a time limit for calculations, and does not even abort
calculations after the window has been closed
(a simple example of this is the expression 123456789!).

Fixes https://github.com/Qalculate/libqalculate/issues/527
FIXED-IN: 5.27.5

M  +7    -2    runners/calculator/qalculate_engine.cpp

https://invent.kde.org/plasma/plasma-workspace/commit/3f3bea079bb55ec70ce248d1238cd0e7e38e5261
Comment 6 Fushan Wen 2023-04-08 08:22:18 UTC
Git commit 207e3e330505829604da07f5593a16135e2019b1 by Fushan Wen.
Committed on 08/04/2023 at 07:41.
Pushed by fusionfuture into branch 'master'.

runners/calculator: set timeout to prevent allocating huge memory

This is not exactly a memory leak. The extreme expression simply
requires huge amounts of memory to calculate.

The calculator runner is problematic since it does not specify
a time limit for calculations, and does not even abort
calculations after the window has been closed
(a simple example of this is the expression 123456789!).

Fixes https://github.com/Qalculate/libqalculate/issues/527
FIXED-IN: 5.27.5


(cherry picked from commit 3f3bea079bb55ec70ce248d1238cd0e7e38e5261)

M  +7    -2    runners/calculator/qalculate_engine.cpp

https://invent.kde.org/plasma/plasma-workspace/commit/207e3e330505829604da07f5593a16135e2019b1