<html><head></head><body>So... You say that your debugging environment sucks.<br><br>That is an argument for you to fix your debugging environment, or use another environment.<br><br>That is not an argument for adding printf debugging to one specific assertion out of many, which does not solve your problem.<br><br><div class="gmail_quote">Le 21 février 2019 13:32:04 GMT+02:00, Steve Lhomme <robux4@ycbcr.xyz> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">On 21/02/2019 11:58, Rémi Denis-Courmont wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"> It's making a special snow flake of that one specific assertion.<br><br> If you want to develop tooling for dumping the object tree, you're <br> much better off scripting your favorite debugger than cluttering one <br> specific VLC assertion.<br></blockquote><br>I don't think that's possible in QtCreator (and that's not my favorite <br>debugger by far), while writing a few lines of code in C is very easy.<br><br>On Windows gdb doesn't break on asserts. It could be enabled to do it, <br>but then everytime I'd run VLC under gdb it breaks 20 times in weird Qt <br>places. So I always end up disabling it. So when a leak occurs (or any <br>assert for that matter) I have to go through this and pray I'll have the <br>leak/assert again.<br><br>><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"> Le 21 février 2019 12:44:44 GMT+02:00, Steve Lhomme <robux4@ycbcr.xyz> <br> a écrit :<br><br>     On 21/02/2019 11:37, Rémi Denis-Courmont wrote:<br><br>         Hi, My GDB skills are bad so I just walked the objects tree by<br>         printing memory content on the abort. It would be much easier<br>         with VLC-specific GDB macros, but the point is that you can<br>         debug that assertion just as any. It also works after the fact<br>         for pseudorandom failures, if you enable core dumps. Much<br>         better than this patch since you have access to all memory,<br>         not just the objects tree. Adding special snow flake debug<br>         code for assertion is a bad idea that sets a very bad<br>         precedent - as opposed to improving integration with proper<br>         debugging tools. <br><br><br>     What's snow flake about adding debug tooling ?<br><br>         Le 21 février 2019 12:26:47 GMT+02:00, Thomas Guillem<br>         <thomas@gllm.fr> a écrit : On Thu, Feb 21, 2019, at 11:18,<br>         Rémi Denis-Courmont wrote:<br><br>             Hi, Well I did debug that assertion failure using (ASan +)<br>             gdb just fine last time. The code has not changed. So this<br>             kludge is definitely not necessary for its alleged purpose. <br><br>         Even if it works with gdb (please tell us how), evelopers<br>         don't always run VLC with gdb. This cause an issue if the leak<br>         is not reproducible...<br><br>             Not only that but stderr is not universally the output for<br>             debug nor is it universally where assertion failures are<br>             dumped to, <br><br>         So if there is no stderr, you don't see the error. I don't see<br>         the problem at all.<br><br>             so this patch does not even work properly <br><br>         Works on Windows, Android, Linux, macOS when VLC is run via<br>         command line. This is the case for most developers usecase.<br><br>             And in most cases you can see the leak by stopping all<br>             inputs and dumping the objects tree before quitting, anyway. <br><br>         What about leaks not related to playback ? Interface, service<br>         discovery, playlist that are only cleaned when vlc is closed.<br><br>             Le 21 février 2019 11:24:57 GMT+02:00, Thomas Guillem<br>             <thomas@gllm.fr> a écrit : Comment: A lot of developers<br>             asked me to propose this patch again. It was previously<br>             refused because developers could use proper debugging<br>             tools. I disagree with that assumption. Even with Asan,<br>             when the leak assert fail, it will abort() without<br>             prompting any leaks, so you'll have to edit libvlc.c to<br>             remove this assert. If your leak was not reproducible,<br>             you'll lose a precious information. And good luck finding<br>             the leak with GDB, you really need to know the internal of<br>             vlc_object_t to iterate through the different list to get<br>             the culprit. Commit log: In case of a vlc_object_t leak,<br>             and if asserts are enabled, the error output will be like<br>             the following (when leaking intentionally decoder_t<br>             objects): === vlc_object LEAKS detected === \ playlist | \<br>             input | | \ decoder avcodec | | | decoder faad | | |<br>             decoder stl<hr>             src/libvlc.c | 30 ++++++++++++++++++++++++++++++ 1 file<br>             changed, 30 insertions(+) diff --git a/src/libvlc.c<br>             b/src/libvlc.c index 8e8d2ca8b2..d9ff96de84 100644 ---<br>             a/src/libvlc.c +++ b/src/libvlc.c @@ -436,6 +436,24 @@<br>             void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )<br>             #endif } +#ifndef NDEBUG +static void<br>             DumpObjectLeaks(vlc_object_internals_t *priv, unsigned<br>             level) +{ + bool first = true; + vlc_list_foreach(priv,<br>             &priv->children, siblings) + { + vlc_object_t *obj =<br>             vlc_externals(priv); + for (unsigned i = 0; i < level;<br>             i++) + fprintf(stderr, " %s ", first && i == level -1 ?<br>             "\\" : "|"); + char *name = vlc_object_get_name(obj); +<br>             fprintf(stderr, "%s %s\n", vlc_object_typename(obj), name<br>             ? name : ""); + free(name); + DumpObjectLeaks(priv, level<br>             + 1); + first = false; + } +} +#endif + /** * Destroy<br>             everything. * This function requests the running threads<br>             to finish, waits for their @@ -449,6 +467,18 @@ void<br>             libvlc_InternalDestroy( libvlc_int_t *p_libvlc )<br>             vlc_ExitDestroy( &priv->exit ); +#ifndef NDEBUG + { +<br>             vlc_object_internals_t *internal =<br>             vlc_internals(p_libvlc); + if<br>             (atomic_load(&internal->refs) != 1) + { +<br>             vlc_mutex_lock(&internal->tree_lock); + fprintf(stderr,<br>             "=== vlc_object LEAKS detected ===\n"); +<br>             DumpObjectLeaks(internal, 1); +<br>             vlc_mutex_unlock(&internal->tree_lock); + } + } +#endif<br>             assert( atomic_load(&(vlc_internals(p_libvlc)->refs)) == 1<br>             ); vlc_object_release( p_libvlc ); } -- Envoyé de mon<br>             appareil Android avec Courriel K-9 Mail. Veuillez excuser<br>             ma brièveté.<hr>             vlc-devel mailing list To unsubscribe or modify your<br>             subscription options:<br>             <a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a> <br><br>         -- Envoyé de mon appareil Android avec Courriel K-9 Mail.<br>         Veuillez excuser ma brièveté.<hr>         vlc-devel mailing list To unsubscribe or modify your<br>         subscription options:<br>         <a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a> <hr>     vlc-devel mailing list<br>     To unsubscribe or modify your subscription options:<br>     <a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br><br><br> -- <br> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez <br> excuser ma brièveté.<hr> vlc-devel mailing list<br> To unsubscribe or modify your subscription options:<br> <a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></blockquote><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a></pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>