Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#12131 closed Patch - Bug Fix (fixed)

Memory leak in LoggingItem::setThreadName()

Reported by: faginbagin <mythtv@…> Owned by: JYA
Priority: minor Milestone: 0.27.2
Component: MythTV - General Version: 0.27-fixes
Severity: medium Keywords:
Cc: Stuart Auchterlonie Ticket locked: no

Description

This inline method is called thousands of times, mostly via MPoolThread::run's calls to loggingRegisterThread, so the old value of m_threadName needs to be freed before a new value is set.

Attachments (1)

logging.patch (776 bytes) - added by faginbagin <mythtv@…> 5 years ago.

Download all attachments as: .zip

Change History (9)

Changed 5 years ago by faginbagin <mythtv@…>

Attachment: logging.patch added

comment:1 Changed 5 years ago by Karl Egly

After a quick look at the patch and file I'm wondering if the various setters that use strdup shouldn't all be doing the same.

comment:2 Changed 5 years ago by faginbagin <mythtv@…>

This setter is the only one that popped up in the valgrind run that prompted me to test and then offer this patch, but that doesn't mean similar changes shouldn't be made to the other setters. I was also wondering if the project has any rules of thumb regarding the size and frequency of use of inline methods. IOW, should this setter (and maybe others) be moved to logging.cpp?

comment:3 in reply to:  1 Changed 5 years ago by Stuart Auchterlonie

Cc: Stuart Auchterlonie added

Replying to dekarl:

After a quick look at the patch and file I'm wondering if the various setters that use strdup shouldn't all be doing the same.

Yes i think they should!

comment:4 Changed 5 years ago by JYA

Owner: set to JYA
Status: newaccepted

comment:5 Changed 5 years ago by Jean-Yves Avenard <jyavenard@…>

Resolution: fixed
Status: acceptedclosed

In c8b359dfec03574bbfb30e2ea7ed0584d34de94d/mythtv:

Tidy up code in logging

There was no leak there. Each functions are only called once as a LoggingItem? isn’t a reusable item

Fixes #12131

comment:6 Changed 5 years ago by Jean-Yves Avenard <jyavenard@…>

In b15009783583edc5c663d09ebb2a7baeeeab2c96/mythtv:

Fix leak in logger

setThreadName can be called twice, obfuscating the previously allocated string

Fixes #12131

comment:7 Changed 5 years ago by Jean-Yves Avenard <jyavenard@…>

In 881284c2f52f5138f2385a0686f38e8b7b14c0c9/mythtv:

Fix leak in logger

setThreadName can be called twice, obfuscating the previously allocated string

Fixes #12131

(cherry picked from commit b15009783583edc5c663d09ebb2a7baeeeab2c96)

comment:8 Changed 5 years ago by paulh

Milestone: unknown0.27.2
Note: See TracTickets for help on using tickets.