Chris Rorvick wrote:
I am seeing my GCC ubsan builds littered with "downcast of address xxxxxxxx which does not point to an object of type 'holder'" errors [3] coming from Boost.Program_options (Boost 1.69). The issue has been documented in various places [1][2] but I do not see anything on the mailing list in recent months; apologies if I have missed something.
A workaround is proposed on the StackOverflow post [1]. Does anyone have any thoughts on this?
Many thanks!
Chris
[1] https://stackoverflow.com/questions/38987728/why-does-boostany-exhibit-undef... [2] https://github.com/boostorg/program_options/issues/76 [3] .../boost/boost/any.hpp:249:17: runtime error: downcast of address 0x602000053610 which does not point to an object of type 'holder' 0x602000053610: note: object is of type 'boost::any::holderstd::string' 6f 00 80 67 d0 91 ec 88 fe 7f 00 00 68 33 09 00 40 60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'boost::any::holderstd::string' ...
This doesn't seem to be the same issue as in the SO link. The cv qualifiers are now being stripped by the constructor at https://github.com/boostorg/any/blob/develop/include/boost/any.hpp#L49 twice (once by `decay` and once by `remove_cv` for added safety) and in your message the held object is non-const:
note: object is of type 'boost::any::holderstd::string'
My guess is that `holder` needs BOOST_SYMBOL_VISIBLE. That is, template<typename ValueType> class holder : public placeholder at https://github.com/boostorg/any/blob/develop/include/boost/any.hpp#L168-L169 needs to be template<typename ValueType> class BOOST_SYMBOL_VISIBLE holder : public placeholder