简体   繁体   中英

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM