Giter VIP home page Giter VIP logo

Comments (7)

robo-todd avatar robo-todd commented on July 4, 2024 1

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.

robo-todd avatar robo-todd commented on July 4, 2024

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.

SanderMertens avatar SanderMertens commented on July 4, 2024

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.

robo-todd avatar robo-todd commented on July 4, 2024

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.

  1. 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.
  2. 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.
  3. 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?
  4. I'll try latest master and report.

from flecs.

SanderMertens avatar SanderMertens commented on July 4, 2024
  1. That sounds like you're running in release mode. RelWiDebInfo likely passes an NDEBUG 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.

robo-todd avatar robo-todd commented on July 4, 2024

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.

SanderMertens avatar SanderMertens commented on July 4, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.