[Live-devel] May createNewSomething methods return NULL?

Helmut Grohne h.grohne at intenta.de
Mon Sep 12 06:16:22 PDT 2016


On Mon, Sep 12, 2016 at 02:02:33PM +0200, Ross Finlayson wrote:
> Rather than making an obscure reference to a 6-year-old message (that was likely in response to something completely different to what you’re concerned about), why don’t you just ask the question you really want to ask?  That way, we’ll all know what your question really is...

To be honest, I was debugging code that uses exactly that advise from
that 6-year-old message to limit the number of active sessions (but I
only discovered that message way later in my debugging). It took me a
while figuring out that returning NULL from createNewClientSession
causes createNewClientSessionWithId to insert a NULL session into the
HashTable fClientSessions. This wouldn't be too bad, but when you
destruct a GenericMediaServer, it turns out that fClientSessions is only
deleted until finding the first NULL pointer. Thus actual ClientSessions
can be leaked. While that also looks like a simple resource leak,
ClientSessions have a fLivenessCheckTask that eventually fires.  When it
does, a use-after-free (on the now deleted GenericMediaServer) can cause
very weired behaviour.

That is what lead me to the initial question: Is it actually ok for
createNewClientSession and others to return NULL? If it is, then you
have a bug. If it isn't, I have a bug (and that 2009 message is no
longer accurate). So whose bug is this?

Helmut


More information about the live-devel mailing list