pa_context_new leaking 4 bytes
I made a very simple program that, according to both Address Sanitizer and Valgrind, leaks 4 bytes. I've tried it on multiple systems but it seems to only happen on some.
Compiled with gcc test.c -lpulse -o test -fsanitize=address
:
#include <stdio.h>
#include <pulse/pulseaudio.h>
int main() {
pa_mainloop *mainloop = NULL;
pa_mainloop_api *mainloop_api = NULL;
pa_context *context = NULL;
if (!(mainloop = pa_mainloop_new())) {
fprintf(stderr, "pa_mainloop_new failed\n");
goto finish;
}
mainloop_api = pa_mainloop_get_api(mainloop);
if (!(context = pa_context_new(mainloop_api, "TEST_NAME"))) {
fprintf(stderr, "pa_context_new failed\n");
goto finish;
}
finish:
if (context) pa_context_unref(context);
if (mainloop) pa_mainloop_free(mainloop);
return 0;
}
Address Sanitizer output:
❯ ./test
=================================================================
==43438==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 4 byte(s) in 1 object(s) allocated from:
#0 0x7f7f87e2bd48 in __interceptor_calloc /build/gcc/src/gcc/libsani
tizer/asan/asan_malloc_linux.cc:153
#1 0x7f7f87cd419f in pa_xmalloc0 (/usr/lib/libpulse.so.0+0xe19f)
#2 0x7f7f87cff301 in pa_context_new_with_proplist (/usr/lib/libpulse
.so.0+0x39301)
#3 0x558a9c3d4269 in main /home/mario/Downloads/test.c:14
#4 0x7f7f87b27022 in __libc_start_main (/usr/lib/libc.so.6+0x27022)
#5 0x558a9c3d410d in _start (/home/mario/Downloads/test+0x110d)
SUMMARY: AddressSanitizer: 4 byte(s) leaked in 1 allocation(s).
Compiling without -fsanitize=address
valgrind.txt, using valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind-out.txt ./test
pa-info.txt for the first Arch Linux setup
test binary compiled on the Arch Linux setup
test_noas same as above, but without -fsanitize=address
test binary compiled on Ubuntu 19.10 with pulseaudio 12.2
Memory leak on:
- Arch Linux, kernel 5.5.4-arch1-1, pulseaudio 13.0, desktop computer
- Arch Linux, kernel 5.5.4-arch1-1, pulseaudio 13.0, laptop computer
- Ubuntu 19.10, kernel 5.3.0-29-generic, pulseaudio 13.0, virtualbox
- Ubuntu 19.10, kernel 5.3.0-29-generic, pulseaudio 12.2, virtualbox
- Ubuntu 18.04, kernel 5.5.4-050504, pulseaudio 13.0, virtualbox
Can't reproduce on:
- Ubuntu 18.04, kernel 5.0-37, pulseaudio 11.1, virtualbox
- Ubuntu 19.04, kernel 5.0.0-13, pulseaudio 12.2, virtualbox
Edited by Mario