KIO: fix long-standing memory leak on exit.
ClosedPublic

Authored by dfaure on Thu, Aug 24, 9:47 PM.

Details

Summary

Slave wasn't really deleted (too late for deleteLater when
the KIO Scheduler global object is being deleted).
But actually deleting led to SlaveKeeper using dangling pointers,
so clear it first.

Detected by heaptrack.

Test Plan

heaptrack bin/jobtest ; valgrind bin/jobtest (to check no use of deleted memory)

Before: total memory leaked 337 kB
After: total memory leaked 232 kB

Diff Detail

Repository
R241 KIO
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
dfaure created this revision.Thu, Aug 24, 9:47 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptThu, Aug 24, 9:47 PM
dfaure updated this revision to Diff 18724.Thu, Aug 24, 11:03 PM
  • Fix leak introduced by first version of the commit, we need to make a copy of the idle list before clearing it.
  • When deleting the slave because it emits a signal, we still need to use deleteLater(), I guess...

The slaveDied() code path isn't unittested, which is why I didn't detect this earlier.

mwolff accepted this revision.Sun, Aug 27, 8:33 PM

lgtm, despite the delete this: https://isocpp.org/wiki/faq/freestore-mgmt#delete-this, esp. if you have proper unit tests and ran it through valgrind

This revision is now accepted and ready to land.Sun, Aug 27, 8:33 PM
dfaure closed this revision.Mon, Aug 28, 7:14 AM