Webserver Segfault

For some reason, our new C++ web application kept segfaulting whenever the user closed the browser. We ignored this problem for a bit, while focusing on functional development. However, it is a nagging problem and I decided to take a look at it today.

The good thing is that by enabling compilation with debugging output, we were able to look into the call stack when it crashed. The suspect was something that was happening in the destructor of our dashboard class.

After a few minutes of scrutiny, it turns out that we were trying to delete some objects from memory in the wrong order.

Most of the objects in Witty were created in a hierarchical manner, reflective of the DOM tree in the browser. Therefore, we had to destroy the objects in a certain order too. It turned out that we had the order reversed in the destructor for our dashboard class.

So, flipping the order around and the segmentation fault disappeared.

You may also like...

Leave a Reply