I'm working on a C program that involves threading within the pthread library, as well as using some mallocs. I was troubleshooting my program and finally got it to where it runs with no memory leaks, and no errors.... sometimes
When I run my executable with valgrind and the following flags: valgrind -s --leak-check=full -v --show-leak-kinds=all
I get the following output:
Same program. If I spam this command in the shell maybe 3/10 times its the "still reachable" text, and the rest of the times it says all my memory blocks were freed.
I'm wondering, how is this even possible? Is this a common occurence when it comes to programs with threading?
Edit: I noticed when I run into the still reachable error, I have 4 less frees than I'm supposed to. Why does this occur?