KIO: fix long-standing memory leak on exit.

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



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

R241 KIO
No Linters Available
No Unit Test Coverage
dfaure created this revision.Aug 24 2017, 9:47 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptAug 24 2017, 9:47 PM
dfaure updated this revision to Diff 18724.Aug 24 2017, 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.Aug 27 2017, 8:33 PM

lgtm, despite the delete this:, esp. if you have proper unit tests and ran it through valgrind

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