[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Memory leaks in C API
From: |
Frederik Gladhorn |
Subject: |
Memory leaks in C API |
Date: |
Thu, 08 May 2014 12:19:33 +0200 |
Torsdag 8. mai 2014 10.31.32 skrev Jarek Czekalski:
> Hi Frederik
>
> The patch nr 2 is definitely something good, though I didn't analyze it
> fully yet. However regarding patches 1 and 3, I have doubts.
>
> xmalloc and xfree could potentially be used to:
> 1. insert breakpoints
> 2. output debug info
That you allocated memory? Great. I'd suggest using proper tools for that.
> 3. using different memory management functions
Sure, re-introducing them will be trivial if someone feels the need. How much
development has this C library seen lately? The largest change recently was
white-space cleanup in 2011.
> 4. introducing additional code monitoring or catching memory leaks
1 and 4: You can do that today. You can also LD_PRELOAD and use address-
sanitizer and valgrind.
> Patches 1,3 would remove this possibility. In general, if something is not
> harmful I would respect original author's ideas.
I'd prefer simplicity and maintainability. Reintroduce it when needed.
>
> Note that I am just a beholder and have no powers in speechd. However I'm
> happy you investigate speech dispatcher api, because recently Google guys
> reported general nature problems with speech dispatcher [1]. To the extent
> that they disabled speech dispatcher support by default. My long term plans
> include getting deeper into this.
I'm not surprised. I didn't look at the actual code yet, only the C API which
is one tiny file.
Cheers,
Frederik
>
> Jarek
>
> [1]
> https://groups.google.com/d/msg/axs-chrome-discuss/PnmzZdvM0Bs/WrAxsN5slEkJ
>
> W dniu 2014-05-08 09:57, Frederik Gladhorn pisze:
> Hi,
>
> I was just playing with the C API of speech
> dispatcher.
>
> The first patch removes xfree which doesn't
> make much sense, it did a nullptr check before calling free.
> The second patch fixes a few memory leaks.
> Note that it adds a function to actually free a connection, that
> was pretty hard work so far.
>
> The third patch I leave up to your judgement,
> it simplifies the code by also getting rid of xmalloc which is
> malloc with a warning and exit if we're out of memory. Imho
> there is no point of handling that and it clutters the code.
> It's quite unlikely that the tiny C client API can do anything
> in case of OOM.
>
> Greetings,
> Frederik
>
>
> _______________________________________________
> Speechd mailing list
> Speechd at lists.freebsoft.org
> http://lists.freebsoft.org/mailman/listinfo/speechd