Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#13412 closed Patch - Bug Fix (fixed)

Valgrind error in threadedfilewriter

Reported by: Klaas de Waal Owned by: Klaas de Waal <klaas.de.waal@…>
Priority: minor Milestone: 31.0
Component: MythTV - General Version: Master Head
Severity: medium Keywords: TFW uninitialized memory
Cc: Stuart Auchterlonie, gigem Ticket locked: no

Description

Running mythbackend with valgrind gives the following error message:

==14156== Conditional jump or move depends on uninitialised value(s)
==14156==    at 0x72CC8A3: ThreadedFileWriter::DiskLoop() (threadedfilewriter.cpp:455)
....
==14156==  Uninitialised value was created by a heap allocation
==14156==    at 0x4838E86: operator new(unsigned long) (vg_replace_malloc.c:344)
==14156==    by 0x667A50E: FileRingBuffer::FileRingBuffer(QString const&, bool, bool, int) (fileringbuffer.cpp:72)

This is line 455 of threadedfilewriter.cpp:

        if (!m_flush && (mwte < 250) && (m_totalBufferUse < kMinWriteSize))

The problem is caused by m_flush; this class member is not initialized when a new instance of ThreadedFileWriter? is created.
The fix is to add initialization of m_flush in threadedfilewriter.h.
Patch is attached.

Attachments (1)

20190223-threadedfilewriter.patch (778 bytes) - added by Klaas de Waal 3 years ago.
Initialize m_flush to false in ThreadedFileWriter? instantiation

Download all attachments as: .zip

Change History (5)

Changed 3 years ago by Klaas de Waal

Initialize m_flush to false in ThreadedFileWriter? instantiation

comment:1 Changed 3 years ago by Klaas de Waal

According to the github history of threadedfilewriter.cpp, this bug is introduced in commit 28b709d on Feb 15, when the initialization has been moved to the header file.

comment:2 Changed 3 years ago by Klaas de Waal <klaas.de.waal@…>

Owner: set to Klaas de Waal <klaas.de.waal@…>
Resolution: fixed
Status: newclosed

In efc9123f4/mythtv:

Fix missing initialization of variable.

Fixes #13412.

Signed-off-by: David Hampton <mythtv@…>

comment:3 Changed 3 years ago by Stuart Auchterlonie

Milestone: needs_triage31.0

comment:4 Changed 3 years ago by Klaas de Waal <klaas.de.waal@…>

In 6fae9af7e/mythtv:

Fix missing initialization of variable.

Fixes #13412.

Signed-off-by: David Hampton <mythtv@…>

Note: See TracTickets for help on using tickets.