jpaver / opengametools

A set of open c++ game development tools that are lightweight, easy-to-integrate and free to use. Currently hosting a magicavoxel .vox full scene loader.
MIT License
375 stars 36 forks source link

Crashes due to unaligned memory access #62

Closed mgerhardy closed 9 months ago

mgerhardy commented 1 year ago
/home/mgerhardy/dev/engine/src/modules/voxelformat/external/ogt_vox.h:1453:55: runtime error: member access within misaligned address 0x619000005581 for type 'struct ogt_vox_keyframe_transform', which requires 4 byte alignment
0x619000005581: note: pointer points here
 00 00 00  58 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00

this is due to the fact that the misc_data allocator is configured for char type - which is a 1 byte alignment - but the struct ogt_vox_keyframe_transform is of course not aligned to 1 byte.

jpaver commented 1 year ago

Interesting, that's easily fixable of course by ensuring the bump allocate rounds up sizes to a multiple of 4 bytes. Out of curiosity, can you say which cpu are you are experiencing this crash on?

mgerhardy commented 1 year ago

this is not cpu or arch related - but address sanitizer related - the apps are crashing in a few cases with the sanitizer being active. which is very unfortunate for the unittests.