Posts

Showing posts from July, 2010

The woes of structure packing - #pragma pack

We were developing an application on Red Hat Enterprise Linux 5.3 that, among other things, needed to use a PCI interface card for acquiring IRIG-B time codes. The Qt 4.5 based application was first developed without this capability, and later the device driver API was integrated to it. The API had a header file with a class declaration and a corresponding source file containing definitions of the class functions. Integrating the API involved adding these two files to the list of the project's source files and making calls to the API functions. This integration caused the application to abruptly crash after receiving SIGABRT signal. The reason reported was along the lines of: “ *** glibc detected *** application_name: malloc(): memory corruption: 0x092a51c8 *** ”. Being a memory error, we used Valgrind to locate any memory access violations. We found that the crash always happened at a single statement that dynamically allocated memory using operator new. The statement