MRPT / mrpt

:zap: The Mobile Robot Programming Toolkit (MRPT)
https://docs.mrpt.org/reference/latest/
BSD 3-Clause "New" or "Revised" License
1.93k stars 630 forks source link

Infinite recursion in basic exception handler #1141

Closed jolting closed 3 years ago

jolting commented 3 years ago

https://github.com/MRPT/mrpt/blob/6cf7cd291eccd9ec101442fd22b0629f71b3cda8/libs/core/src/exceptions.cpp#L95

This should be

const auto* ecb = dynamic_cast<const ExceptionWithCallBackBase*>(&e);
if(ecb)
{
  ret = ecb->originalWhat;
}
else
{
  ret = e->what();
}

Since m_what is empty.

call exception_to_str https://github.com/MRPT/mrpt/blob/78c8f30facd9994880a2b16157e55e25b93b2312/libs/core/src/exceptions.cpp#L105 call impl_excep_to_str https://github.com/MRPT/mrpt/blob/78c8f30facd9994880a2b16157e55e25b93b2312/libs/core/src/exceptions.cpp#L51 call basic version https://github.com/MRPT/mrpt/blob/78c8f30facd9994880a2b16157e55e25b93b2312/libs/core/src/exceptions.cpp#L100 call e.what(), m_what is still empty https://github.com/MRPT/mrpt/blob/78c8f30facd9994880a2b16157e55e25b93b2312/libs/core/include/mrpt/core/exceptions.h#L95 repeat steps 1-4.

jolting commented 3 years ago

Potential fix: https://github.com/jolting/mrpt/tree/infiniteExceptions

jlblancoc commented 3 years ago

Wow!! Excellent finding.