Bug 368674 - partition manager crashes while checking highly corrupted partition (memory leak)
Summary: partition manager crashes while checking highly corrupted partition (memory l...
Status: RESOLVED FIXED
Alias: None
Product: partitionmanager
Classification: Applications
Component: general (other bugs)
Version First Reported In: 1.2.1
Platform: Kubuntu Linux
: NOR crash
Target Milestone: ---
Assignee: Andrius Štikonas
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-12 05:44 UTC by Fayaz Yusuf Khan
Modified: 2017-09-15 14:01 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fayaz Yusuf Khan 2016-09-12 05:44:51 UTC
Some context: 
My (ext4) partition is 207GiB in size.
It had underwent some resize and move operations previously. After that the partition remained corrupted. I tried using alternate superblocks without any success. As a final effort I tried the "mkfs.ext4 -S".
The subsequent 'fsck' is a seemingly never ending stream of "inode x invalid, clear? (y)" prompts.

So I tried the "Check" option in the partition manager.
But it runs for an hour until it slowly consumes all RAM (3.9GiB) and swap (3.8GiB) and then simply exits. No crash dialog is produced however.

Reproducible: Always

Steps to Reproduce:
1. Setup a large partition with several corrupted inodes.
2. Check the partition using partition manager.

Actual Results:  
Process consumes all memory and exits afterwards.

Expected Results:  
Handle the memory spike gracefully.
Comment 1 Andrius Štikonas 2016-09-12 11:26:36 UTC
I think what happens is that output from e2fsck is stored in a variable in KPM. e2fsck keeps producing more and more output and uses more and more memory.

We can already do command timeout but that will probably not work because some normal file system checks sometimes take a long time to happen, I saw one lasting about 50 minutes.

One way to fix this might be to add a limit to stored output and exit with error when that limit is reached.
Comment 2 Andrius Štikonas 2017-09-15 14:01:17 UTC
Git commit 687e3fc7d44c55e2529084518cb4780065dab2cb by Andrius Štikonas.
Committed on 15/09/2017 at 13:59.
Pushed by stikonas into branch 'master'.

Do not store more than 10M characters in ExternalCommand output.

M  +6    -0    src/util/externalcommand.cpp

https://commits.kde.org/kpmcore/687e3fc7d44c55e2529084518cb4780065dab2cb