Skip to content

The flecs cpp API invokes ub in flecs::opaque #1417

@Gaspard--

Description

@Gaspard--

Flecs is invoking undefined behaviour by casting function pointers with reinterpret_cast in many functions of flecs::opaque and then calling them with the wrong signature:

opaque& serialize(flecs::serialize<T> func) {
this->desc.type.serialize =
reinterpret_cast<decltype(
this->desc.type.serialize)>(func);
return *this;
}

Caught using -fsanitize=undefined under clang.
The fix seems more complicated than #1416 because we need to somehow pass a function pointer that would call the other function pointer, or find some other trick.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions