I just learnt about deep recursion and I'm not sure if my code, which uses boost::asio is under the risk of deep recursion, therefor, a stack overflow. Here is the code:
//read_buf is member of Client, defined as : asio::streambuf read_buf;
void Client::handleRead(asio::error_code& ec)
{
std::ostringstream ss;
ss << &read_buf;
std::string readRemainder = ss.str();
size_t index;
while ((index = readRemainder.find('\x1F')) != std::string::npos)
{
//process the message here
readRemainder.erase(readRemainder.begin(), readRemainder.begin() + index + 1);
}
asio::async_read_until(*sock, read_buf, '\x1F', bind(&Client::handleRead, this, ec));
}
}
Since this code uses async_read_until, It exists the method right after calling itself recursively. But since it exists, I thought there wouldn't be a stack overflow issue. But when I shared the code with an AI, it said there is a potential deep recursion risk and a potential stack overflow issue.
Do you think there is a deep recursion / stack overflow risk with this code?