Skip to content
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

Crash caused by entity::each passing stage to ecs_type_match #525

Closed
BHolman-LBI opened this issue Nov 3, 2021 · 1 comment
Closed

Crash caused by entity::each passing stage to ecs_type_match #525

BHolman-LBI opened this issue Nov 3, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@BHolman-LBI
Copy link
Contributor

Describe the bug
The following snippet is triggering an exception from what looks like memory corruption.

To Reproduce

struct AtrValue
{
    float Value;
};

struct BodyPart
{
    float Health;
};

int main()
{
    
    flecs::world ecs;

    auto Str = ecs.entity("Str");
    auto Agi = ecs.entity("Agi");

    auto Chest = ecs.entity("Chest");
    auto Leg = ecs.entity("Leg");

    auto e = ecs.entity()
        .set<AtrValue>(Str, {5})
        .set<AtrValue>(Agi, {6})
        .set<BodyPart>(Chest, {10})
        .set<BodyPart>(Leg, {7});

    ecs.system<AtrValue>()
        .arg(1).obj(Str)
        .iter([](flecs::iter& Iter, AtrValue* AtrValues)
        {
            for(auto i : Iter)
            {
                auto e = Iter.entity(i);
                e.each<BodyPart>([&](flecs::entity Key)
                {
                    printf("%s\n", Key.str().c_str());
                });
            }
        });

    ecs.progress();
}
@BHolman-LBI BHolman-LBI added the bug Something isn't working label Nov 3, 2021
@SanderMertens SanderMertens changed the title Memory Corruption when using .each Crash caused by entity::each passing stage to ecs_type_match Nov 4, 2021
@SanderMertens
Copy link
Owner

Fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants