You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In one of my tests, subscribing to an already subscribed topic results in crash inside the SDK. Here is the test sequence:
1. connect
2. subscribe to a topic, TopicA
3. disconnect
4. connect
5. subscribe again to TopicA ------> CRASH!!
I found the code causing the crash to be below in Subscribe.cpp:
ResponseCode SubscribeActionAsync::PerformAction(std::shared_ptr<NetworkConnection> p_network_connection, std::shared_ptr<ActionData> p_action_data) {
....
// Read running in separate thread, Insert before sending request to avoid situations where response arrives early
util::Vector<std::shared_ptr<Subscription>>::iterator itr = p_subscribe_packet->subscription_list_.begin();
while (itr != p_subscribe_packet->subscription_list_.end()) {
util::String topic_name = (*itr)->GetTopicName()->ToStdString();
auto existing_itr = p_client_state_->subscription_map_.find(topic_name);
if (p_client_state_->subscription_map_.end() != existing_itr) {
if (existing_itr->second->IsActive()) {
itr = p_subscribe_packet->subscription_list_.erase(itr);
}
} else {
p_client_state_->subscription_map_.insert(std::make_pair(topic_name, (*itr)));
}
itr++;
}
...
I think when subscribing to an already subscribed topic, the code is erasing an element from p_subscribe_packet->subscription_list_ vector here while iterating the same and advancing the iterator afterwards here which causes the crash.
I would be happy to submit a fix.
The text was updated successfully, but these errors were encountered:
Hi @shekharhimanshu,
I'm able to reproduce it and I've added it into our backlog for the next release. If you have a fix, could you please submit a pull request? It would be good to compare all approaches to the issue.
Thanks a lot for your help!
Varun
Hello,
In one of my tests, subscribing to an already subscribed topic results in crash inside the SDK. Here is the test sequence:
I found the code causing the crash to be below in Subscribe.cpp:
I think when subscribing to an already subscribed topic, the code is erasing an element from
p_subscribe_packet->subscription_list_
vector here while iterating the same and advancing the iterator afterwards here which causes the crash.I would be happy to submit a fix.
The text was updated successfully, but these errors were encountered: