简体   繁体   English

服务器崩溃后尝试在套接字上调用recv时,SIGBUS(Android 6.0.1)

[英]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. 在这种情况下, fd是一个TCP套接字。 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) SIGBUS(信号SIGBUS:非法对齐)

It only seems to happen on Android 6.0.1 and I can't seem to 'ignore' the SIGBUS using 它似乎只发生在Android 6.0.1上,我似乎无法使用“忽略” SIGBUS

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 . 它与recv的调用无关。 The signal occurs when and std::exception is being throws on Android 6.0.1. 该信号在Android 6.0.1上引发and std::exception时发生。 Even though it blames the recv call. 即使它归咎于recv电话。 This seemed to be caused by the c++_shared STL version I am using. 这似乎是由我使用的c ++ _ shared STL版本引起的。 The solution was to switch to gnustl_static or gnustl_shared . 解决方案是切换到gnustl_staticgnustl_shared

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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