Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

rdsn: fix asio_rpc_session bug which may cause double free #115

Merged
merged 3 commits into from
Jun 29, 2018

Conversation

qinzuoyan
Copy link
Member

@qinzuoyan qinzuoyan commented Jun 29, 2018

to fix #114

原因是:在asio_network_provider::do_accept()中,新建的asio_rpc_session的构造函数中,调用了start_read_next(),进一步调用 asio_rpc_session::do_read():先add_ref(),如果立即调用回调函数,会release_ref(),如果该release_ref()发生在构造函数返回之前,这个新建的对象asio_rpc_session就会被立即析构。在构造函数返回之后,do_accept()中继续持有和使用该对象,就会造成double free。

解决办法:asio_rpc_session的构造函数中不调用start_read_next(),而是在对象创建完成后,在外面调用start_read_next()。

@qinzuoyan qinzuoyan added the type/bug This issue reports a bug. label Jun 29, 2018
_magic = 0xfacedead; // 4207861421
}
// 0xdeadbeef: 3735928559
dassert(_magic == 0xdeadbeef, "memory corrupted, could be double free or others");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utility下暂时先别用dassert了,我希望把utility做成不依赖rdsn环境的一个package。等后面把dassert剥离得可以不依赖rdsn runtime了,再慢慢引入吧。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, and add issue apache/incubator-pegasus#102

@qinzuoyan qinzuoyan merged commit 044ce72 into master Jun 29, 2018
@qinzuoyan qinzuoyan deleted the qinzuoyan1 branch June 29, 2018 08:12
@neverchanje neverchanje added type/bug-fix This PR fixes a bug. and removed type/bug This issue reports a bug. labels Mar 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/bug-fix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(rpc): server core when close socket in thrift_message_parser::get_message_on_receive
4 participants