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

Prefabs got fatal: allocator.c: 52: assert: size >= 0 INTERNAL_ERROR on exit #1391

Open
KienTTran opened this issue Oct 8, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@KienTTran
Copy link

KienTTran commented Oct 8, 2024

Describe the bug

Hi,
Thanks for making this increadible lib.
I tried to create 50M entities with prefabs but got error: fatal: allocator.c: 52: assert: size >= 0 INTERNAL_ERROR when program is finished.

To Reproduce

#include <flecs.h>
#include <iostream>

struct Position {
    float x, y, z;
};
struct Velocity {
    float vx, vy, vz;
};
int main(int argc, char *argv[]) {
    flecs::world ecs(argc, argv);
    auto person_prefab = ecs.prefab("PersonPrefab")
        .set<Position>({0, 0, 0})
        .set<Velocity>({0, 0, 0});
    for (int i = 0; i < 50000000; i++) {
        ecs.entity()
            .is_a(person_prefab)
            .add<Position>()
            .set<Position>({static_cast<float>(i), 0, 0});
    }
    std::cout << "Created 50,000,000 entities" << std::endl;
    return 0;
}

it gave error:

Created 50,000,000 entities
fatal: allocator.c: 52: assert: size >= 0 INTERNAL_ERROR
1   TestECS                             0x0000000102a45aa8 flecs_log_msg + 1676
2   TestECS                             0x00000001029ac20c ecs_printv_ + 212
3   TestECS                             0x00000001029ac398 ecs_log_ + 100
4   TestECS                             0x00000001029ac118 ecs_assert_log_ + 264
5   TestECS                             0x0000000102a0b184 flecs_allocator_get + 72
6   TestECS                             0x0000000102a17c70 ecs_vec_set_size + 212
7   TestECS                             0x0000000102a18038 ecs_vec_append + 88
8   TestECS                             0x0000000102a78af0 flecs_cmd_new + 40
9   TestECS                             0x0000000102a78c14 flecs_defer_delete + 44
10  TestECS                             0x0000000102a224fc ecs_delete + 324
11  TestECS                             0x0000000102aa0174 flecs_fini_root_tables + 1164
12  TestECS                             0x0000000102a9aa88 flecs_fini_roots + 148
13  TestECS                             0x0000000102a9a6d4 ecs_fini + 1096
14  TestECS                             0x0000000102994f50 _ZN5flecs5world7releaseEv + 140
15  TestECS                             0x0000000102994eac _ZN5flecs5worldD2Ev + 28
16  TestECS                             0x000000010296ab80 _ZN5flecs5worldD1Ev + 28
17  TestECS                             0x000000010296a894 main + 440
18  dyld                                0x0000000190de8274 start + 2840

Process finished with exit code 134 (interrupted by signal 6:SIGABRT)

The error is after created entities but before the return line. It works fine for smaller number like 5M entities.

Btw, is this the correct way to use prefab?

Expected behavior
Should return no error

Additional context
My specs is M3 base 24GB RAM. Free RAM is around 20% when running the code.

@KienTTran KienTTran added the bug Something isn't working label Oct 8, 2024
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

1 participant