Comments (7)
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.
from flecs.
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.
from flecs.
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 entities
is either NULL
(likely) or a bad address (that would be bad). That's very odd, the only table that I can think of for which entities
is NULL
is the root table, and it should never get matched with a query.
EDIT: it could also be that var->range.offset
is out of range for the array, which could point to a bug in the engine.
A couple of things to verify/try out:
- Is it possible that multiple threads are accessing/mutating the flecs world? Flecs APIs are not inherently thread safe, so any mutation on the world while the REST API is attempting to read it could cause a crash
- Are you running the application in debug mode? This could show additional information about the issue
- Are you able to tell for which query the issue is occurring? (should be able to figure out by checking the network tab in the browser devtools). If it's a user query, can you share which one?
- Is the issue reproducible on latest master?
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.
from flecs.
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.
- In this configuration I'm not running the application multithreaded even for flecs threads. It is just the progress loop. There are threads in the application, but specifically isolated from any flecs calls/structure mutation. I'll double check this.
- This happens just running the flecs explorer on the main tab with no query in the query interface. I can connect to the running application and things are fine. I can look around, check out entities, components, etc. see my component definitions and the moment that I open a UI box (which is triggered by adding the 'tag' to a top-level UI entity) the app continues running until the next REST 'update' comes through. It takes like ~1 second for the refresh to hit.
- When I've built the application in Debug I don't get much more from gdb. The build above is RelWiDebInfo settings in CMAKE. Maybe I need to read up is Debug mode a switch to the engine?
- I'll try latest master and report.
from flecs.
- That sounds like you're running in release mode.
RelWiDebInfo
likely passes anNDEBUG
flag when compiling, which disables things like asserts. It's possible/likely that whatever is causing this will error out with an assert.
You should be able to enable debug mode with:
-DCMAKE_BUILD_TYPE=Debug
from flecs.
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.
from flecs.
I'd build both of them in debug.
But as soon as I add one to the UI entity I get the crash.
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.
from flecs.
Related Issues (20)
- observer loss event HOT 2
- [Question] Best way to share a component between differents entities HOT 3
- README link is broken HOT 1
- Compilation failed with errors when declaring 'free' as a macro. HOT 1
- Explorer hierarchy incomplete HOT 6
- free(): invalid pointer when using sorted query with std::list HOT 1
- Bug or question - HOT 1
- Lockstep support, or deterministic calculations. HOT 7
- filter_builder() assert fail, when use term().or_() HOT 2
- Queries with Or terms and wildcard terms cause internal error HOT 1
- entity::set(T*) writes garbage HOT 1
- flecs crashes at startup when using clang built from git
- I get exception errors in ms visual studio 2019 before the main function HOT 7
- Unintuitive behavior of setting entity names as numbers HOT 4
- Enabling or disabling a component between defer_suspend and defer_resume keeps the world deferred after progress HOT 2
- World destruction with symmetric relationship and child causes assertion HOT 3
- Add flecs.c and flecs.h as download artefacts for releases HOT 3
- Strings not freed on runtime components HOT 6
- ecs_set() doesn't work C HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flecs.