Identify Heap Contention Errors
Explore how to identify heap contention errors such as double free issues in multithreaded Linux applications by analyzing core dumps. Understand thread states, stack traces, and memory operations to spot concurrency problems causing crashes. This lesson guides you through debugging shared memory allocation errors to improve your diagnostic skills.
Application source code
We’ll be analyzing the core dump generated from the following file:
We can see that several threads are allocating and freeing memory using a shared array of pointers. If you execute this application, you’ll get the double free error:
Double free errors occur when the free() function is called twice on a pointer. In this lesson, we’ll learn how to identify such errors in a multithreaded environment.
Loading the core dump
Let’s begin by loading the generated core dump:
gdb -c core.App10 -se App10
The above command will output the following to the terminal:
Listing all threads
Let’s take a look at the list of threads and identify the top frames at the time of the crash:
info threads
The above command will output the following to the terminal:
We ...