Blog Archives

Heap Segmentation Fault – caused by declaration location/scope

Unexpected segmentation faults? Might be your variable declaration.

Here’s the point, declaring variables as global, is commonly known as “do you really need to?” .
Especially if it’s a dynamic sized data structure, like a C++ list.
Yeah  I realized the hard way, the size grew out of static memory bounds and got into the heap.

Good old GDB to the rescue, those error messages might be a mystery at first, it’s still potentially a beacon of hope.