emilk / loguru

A lightweight C++ logging library
The Unlicense
1.76k stars 256 forks source link

Valgrind memory loss reported for call to pthread_setspecific #209

Open mennodeij opened 2 years ago

mennodeij commented 2 years ago

Good morning,

In a program that uses VTK (see https://gitlab.kitware.com/vtk/vtk) loguru is used as third party logging for VTK. When I run a program that uses VTK and loguru through valgrind, I see the following:

==2056936== 8 bytes in 1 blocks are definitely lost in loss record 5 of 20,285
==2056936==    at 0x64E50A5: malloc (vg_replace_malloc.c:380)
==2056936==    by 0x1512E80D: strdup (in /usr/lib64/libc-2.28.so)
==2056936==    by 0x329F8C77: vtkloguru::set_thread_name(char const*) (loguru.cpp:923)

It looks like the string passed to pthread_setspecific to set the thread name is duplicated with STRDUP, but never freed. Currently this is on line 1033 in loguru.cpp.