Projects > cpp > Issues > Bug #4542

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

websocket cash in win32

Bug #4542 [Closed]
jingbin.chen@chukong-inc.com 2014-03-25 02:27 . Updated over 2 years ago

when receive message, use std::lock_guard in WsThreadHelper::update then call in onUIThreadReceiveMessage, will result to delete _wsHelper. While the mutex of _UIWsMessageQueueMutex is still lock, lead to crash. The crashed situation the same as following:

class TestA
{
public:
void deleteSelf();
protected:
private:
std::mutex m;
};

void TestA::deleteSelf()
{
std::lock_guardstd::mutex lk(m);
delete this; // while m is still lock, can not delete directly
}

int _tmain(int argc, _TCHAR* argv[])
{
TestA a;
a.deleteSelf();
return 0;
}

jingbin.chen@chukong-inc.com 2014-03-25 02:32

just wrap the codes of mutex in another function can solve.

jingbin.chen@chukong-inc.com 2014-03-25 02:37
  • Status changed from New to Resolved
Anonymous 2014-03-25 08:35
  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100

Applied in changeset commit:2d98ab252b18139691146198038115cf79d17a91.

Atom PDF

Status:Closed
Start date:2014-03-25
Priority:Normal
Due date:
Assignee:jingbin.chen@chukong-inc.com
% Done:

100%

Category:windows
Target version:3.0-rc1

Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.