I am running QEMU on a Ubuntu 20.04.2 machine, and have a GDB debugger attached to it.
I breaked at a line which does g_malloc
. The return address does not belong to the heap memory region, where the virtual memory addresses are found via cat /proc/$PID/maps
. I did a visual match of the return address against the output of maps
, and found it in a data segment. This does not always happen - on some occasions, the return address is indeed found in the heap region.
I have read that "The addresses returned by malloc and related functions come from whatever area your run-time environment uses for dynamic memory." Does this mean that
g_malloc
andmalloc
in general do not necessarily allocate memory in the heap region? I tried to search if this was true but what I found was that every search result says that it is only returning addresses in the heap.I have also read that "heap is actually part of the data segment of the executable itself". Again, I tried to search for an explanation about this statement, but found that others just said not to mix the heap and data segments together - and to see them being disparate.
I am unable to reconcile my above 2 readings with my findings.