PRE-2016 Valgrind: Still Reachable Leak detected by Valgrind

There is more than one way to define “memory leak”. In particular, there are two primary definitions of “memory leak” that are in common usage among programmers. The first commonly used definition of “memory leak” is, “Memory was allocated and was not subsequently freed before the program terminated.” However, many programmers (rightly) argue that certain … Read more

Should I use Helgrind or DRD for thread error detection?

While Helgrind can detect locking order violations, for most programs DRD needs less memory to perform its analysis. Also, DRD has support for detached threads. There are more subtle differences too – compare the respective manuals if you want to know more. See also http://valgrind.org/docs/manual/hg-manual.html and http://valgrind.org/docs/manual/drd-manual.html.

Valgrind Unrecognised instruction

In fact, Valgrind emulate your program with an intermediate language (VEX) to know if it discovers memory violation. This VEX language capture all the instructions of several assemblers such as i386, amd64, arm, … But, from time to time, it miss a few instructions (especially specialized ones like rdrand which is linked to the AES … Read more

What is the difference between a direct and indirect leak?

The LSan wiki design document states: Another useful feature is being able to distinguish between directly leaked blocks (not reachable from anywhere) and indirectly leaked blocks (reachable from other leaked blocks). Stated another way, indirect leaks are a result of direct leaks. Fixing direct leaks should make the indirect leaks become either fixed or direct … Read more

Invalid read of size 8 – Valgrind + C

The problem is that you’re freeing the sym, then trying to access a value from the (now-freed) data: sym->next. You probably want something like this for the inner loop: struct symbol *next_sym = NULL; for(sym = st[i]; sym != NULL; ) { next_sym = sym->next; free(sym); sym = next_sym; }

valgrind memory leak errors when using pthread_create

A thread’s resources are not immediately released at termination, unless the thread was created with the detach state attribute set to PTHREAD_CREATE_DETACHED, or if pthread_detach is called for its pthread_t. An undetached thread will remain terminated state until its identifier is passed to pthread_join or pthread_detach. To sum it up, you have three options: create … Read more

Why does valgrind say basic SDL program is leaking memory?

Even for basic OpenGL “hello world” program without the full SDL, Valgrind gives me similar warnings deep inside the OpenGL libraries. It’s peculiar, but I’ve assumed The library implementors know what they’re doing (probably preallocating some small static buffers they never bother to free), Even if they don’t, it’s a one-time leak that’ll be reclaimed … Read more

Terminate process running inside valgrind

There is no “inner process” as both valgrind itself and the client program it is running execute in a single process. Signals sent to that process will be delivered to the client program as normal. If the signal causes the process to terinate then valgrind’s normal exit handlers will run and (for example) report any … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)