androidsocketsandroid-ndksignalssigbus

SIGBUS when trying to call recv on socket after server crash (Android 6.0.1)


I am currently doing some app stability testing and I am running in to an issue when calling the following method;

    vector<char> buffer( 256 ); 
    received = recv( fd, buffer.data(), buffer.size(), MSG_NOSIGNAL );

In this case fd is a TCP socket. When the above code is called and simultaneously the server side of the socket goes down in one way or another I get the following signal;

SIGBUS (signal SIGBUS: illegal alignment)

It only seems to happen on Android 6.0.1 and I can't seem to 'ignore' the SIGBUS using

signal(SIGBUS, SIG_IGN)

Has anyone else run in to this problem and what would be the best approach to solve this?


Solution

  • Oke, I have found out the issue. It has NOTHING to do with the call to recv. The signal occurs when and std::exception is being throws on Android 6.0.1. Even though it blames the recv call. This seemed to be caused by the c++_shared STL version I am using. The solution was to switch to gnustl_static or gnustl_shared.