Skip to content Skip to sidebar Skip to footer

Android Ndk: C++ Struct Member Access, Causes Sigbus (signal Sigbus: Illegal Alignment)

I'm porting a C++ library on Android (Android Studio 2.3.1/NDK 25); the library works flawlessly on UWP (VS2017 VC 1.41 - ARM & Win32) a custom ARM7 board (GCC 4.8). When debug

Solution 1:

I had exactly the same issue.

In your code snippet, secPtr is not aligned because it points to buffer offseted by 1(sizeof(_t_u8)) byte. (assuming that buffer is aligned address)

All 4-byte ailgned memory addresses should end in '0', '4', '8' or 'C'. Since secPtr ends in '5', it is not aligned.

ARM processors support some of unaligned memory access. That is why secPtr->crc32 = 0; is legal, but secPtr->counter= 0; is not.

Try removing 1-byte offset in secPtr somehow and see if the problem goes away.

Also check out this page for detailed information: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka15414.html

Post a Comment for "Android Ndk: C++ Struct Member Access, Causes Sigbus (signal Sigbus: Illegal Alignment)"