-
-
Notifications
You must be signed in to change notification settings - Fork 448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ECS crash after conditionally adding to an entity when using Explorer #1180
Comments
I'm starting to run into this in other places. It seems like if I "add" a tag (a struct that has been declared as a component) that has no contents. Flecs explorer does not handle this case somehow? I must be doing something wrong, but anything that has a tag added kills the process inside of the REST response. |
According to the stack trace it's crashing on this line: ecs_entity_t *entities = table->data.entities.array;
var->entity = entities[var->range.offset]; // <-- suggesting that EDIT: it could also be that A couple of things to verify/try out:
If that doesn't help, are you able to share a reproducer with example code that crashes the explorer? It can't just be related to adding tags, that's something that would've crashed any app connected to the explorer. |
Thanks for reviewing. I'll see what I can do to add to it. I can't quite get a smaller repro. Only happens in large application right now.
|
You should be able to enable debug mode with:
|
Just making sure I need to rebuild flecs with Debug or just my application? Also another tidbit of information: The application has all kinds of tag data structures entity.add() all over the place that are set before the main loop starts while loading things up. This appears to cause no issues. But as soon as I add one to the UI entity I get the crash. |
I'd build both of them in debug.
Right, that's what's leading me to believe it could have something to do with multithreading. If a thread is adding a tag at the same moment as the REST API is querying the world, a crash could happen. If that's not the case, it's possible that the world was already in a bad state. Asserts should catch most of that and provide more information on what's happening. |
Following up: I ran everything in the debug builds of current flecs release and mainline. This helped me backtrace the problem. This is 100% my bug and not a flecs engine issue. Thanks for the advice on running with debug build of flecs. I was really scratching my head before that. |
I'm working with a large flecs application in C++ and have been progressively adding in meta support for using with flecs explorer.
The application uses tags (empty structs of a specific type) and adds them to entities to turn on/off various rendering options.
The application itself works fine and has had no issues with this.
When I connect flecs explorer and then add a tag to an entity (during the execution of a system that checks UI inputs) flecs itself crashes after this happens. It is 100% reproducible.
The line of code that adds things is the following (where ui_root is an entity that has a bunch of these tags on it). ShowActuatorStates is just a 'tag' struct and showActuatorStates is a boolean variable.
ui_root.add_if<ShowActuatorStates>(showActuatorStates);
This normally flips my visualizer rendering of various things on and off just fine, but with explorer connected it seems to crash on the next loop after this is executed.
Additional context
This is on Ubuntu 22.04, Flecs v3.2.11, gcc 11.4.0-1ubuntu1~22.04
Here is the crash dump from gdb when this happens:
The text was updated successfully, but these errors were encountered: