Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maybe core in pong_timeout_handler #844

Open
chinchilla-forest opened this issue Oct 11, 2019 · 1 comment
Open

maybe core in pong_timeout_handler #844

chinchilla-forest opened this issue Oct 11, 2019 · 1 comment

Comments

@chinchilla-forest
Copy link

Hi I find a problem about pong_timeout_handler.
In file connection_impl.hpp,I see if endpoint send a ping to remote,a m_ping_timer will be create,and it will save the share_ptr of the connect.If the remote doesn't response the pong,the m_pong_timeout_handler will be called. Some case will lead to core.

Step1. create a object named WClient ,the websocketpp ppclient is a member of WClient.
Step2.set the member function(handle_pong_timeout) of WClient to ppclient as the pong_timeout_handler。
step3. create connect to a remote server,send a ping to server after connect created.
step4.the server doesn't response pong.And close the the connect
step5.the WClient receive close message,and free the WClient object.So the pong_timeout_handler is invalid.

step6. but the ppclient is not freed because it will save the share_ptr of itself when create the ping timer.

step7.the ping timer will be called because the client doesn't receive a pong from remote.
step8.so the WClient will call handle_pong_timeout,then call m_pong_timeout_handler.
but m_pong_timeout_handler is invalid, so it will generate a core file.

@chinchilla-forest
Copy link
Author

chinchilla-forest commented Oct 11, 2019

I think it is better to check the staus if is open when call m_pong_timeout_handler.if not,may be the handler is invaild .
in file connection_impl.hpp
template
void connection::handle_pong_timeout(std::string payload,
lib::error_code const & ec)
{
if (ec) {
if (ec == transport::error::operation_aborted) {
// ignore, this is expected
return;
}

    m_elog->write(log::elevel::devel,"pong_timeout error: "+ec.message());
    return;
}

//////////////////////////////////// my advice
{
scoped_lock_type lock(m_connection_state_lock);

if (m_state != session::state::open) {
   return;
 }

}
////////////////////////////
if (m_pong_timeout_handler) {
m_pong_timeout_handler(m_connection_hdl,payload);
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant