There has been a bug report where a duckdb-wasm user manage to relyably have a std::bad_cast thrown by duckdb-wasm.
This is likely due to a combinations of problems:
1) duckdb using dynamic_cast<Derived&> that might lead to a throw std::bad_cast if the RTTI do not match
2) some yet to be identified problem that leads to a mismatch (possibly uninitialised memory or some other logical error)
3) duckdb-wasm not addressing throws properly in all possible callsites (work in progres)
This PR adds an experimental checked_dynamic_cast that do check whether a cast will throw, and in that case log this to console AND throw a FatalError.
This will hopefully make failures due to 2 more visible and have them fail better and more clearly.
(+ other few places where dynamic_cast on a reference has been changed to checked_dynamic_cast)
that is a bit rough (std::cout ...) but should work for now to track this down.
This should likely be considered in a similar form also duckdb-side.
There has been a bug report where a duckdb-wasm user manage to relyably have a std::bad_cast thrown by duckdb-wasm.
This is likely due to a combinations of problems: 1) duckdb using dynamic_cast<Derived&> that might lead to a throw std::bad_cast if the RTTI do not match 2) some yet to be identified problem that leads to a mismatch (possibly uninitialised memory or some other logical error) 3) duckdb-wasm not addressing throws properly in all possible callsites (work in progres)
This PR adds an experimental checked_dynamic_cast that do check whether a cast will throw, and in that case log this to console AND throw a FatalError.
This will hopefully make failures due to 2 more visible and have them fail better and more clearly.
Added patch is:
(+ other few places where dynamic_cast on a reference has been changed to checked_dynamic_cast) that is a bit rough (std::cout ...) but should work for now to track this down. This should likely be considered in a similar form also duckdb-side.