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

Assert in ecs_cpp_trim_module #1555

Open
unelegal opened this issue Feb 6, 2025 · 5 comments
Open

Assert in ecs_cpp_trim_module #1555

unelegal opened this issue Feb 6, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@unelegal
Copy link

unelegal commented Feb 6, 2025

Describe the bug
ecs_cpp_trim_module tries to trim the name of the module from a type instead of just the namespace, which leads to the assert invalid C++ type name failing.

To Reproduce

#include <flecs.h>

struct module_a_component { };

class module_a {
public:
    module_a(flecs::world &world) {
        world.component<module_a_component>();
    }
};

int main() {
    flecs::world world;
    world.import<module_a>();

    return 0;
}

Expected behavior
This minimal example should work I guess, unless I'm being stupid 😅

@unelegal unelegal added the bug Something isn't working label Feb 6, 2025
Reddy-dev added a commit to Reddy-dev/Unreal-Flecs that referenced this issue Feb 11, 2025
@Reddy-dev
Copy link
Contributor

@unelegal is my test not the same as your example? as doesnt seem to give an assert

@SanderMertens
Copy link
Owner

Running the above code does give me the assert:

fatal: flecs.c: 21099: assert: type_name[0] == ':' invalid C++ type name (INVALID_PARAMETER)
1   cpp_test_2                          0x000000010439aea8 flecs_log_msg + 1676
2   cpp_test_2                          0x00000001043c3954 ecs_printv_ + 212
3   cpp_test_2                          0x0000000104370988 ecs_log_ + 116
4   cpp_test_2                          0x0000000104363ddc ecs_assert_log_ + 184
5   cpp_test_2                          0x00000001043bd59c ecs_cpp_trim_module + 408
6   cpp_test_2                          0x00000001043bddc4 ecs_cpp_component_register + 388
7   cpp_test_2                          0x000000010435ac9c _ZN5flecs1_9type_implI18module_a_componentE11register_idEP11ecs_world_tPKcbybbS7_y + 648
8   cpp_test_2                          0x000000010435a8d4 _ZN5flecs9componentI18module_a_componentEC2EP11ecs_world_tPKcby + 480
9   cpp_test_2                          0x000000010435a6c0 _ZN5flecs9componentI18module_a_componentEC1EP11ecs_world_tPKcby + 88
10  cpp_test_2                          0x000000010435a620 _ZNK5flecs5world9componentI18module_a_componentJEEENS_9componentIT_EEDpOT0_ + 64
11  cpp_test_2                          0x000000010435a5a4 _ZN8module_aC2ERN5flecs5worldE + 52
12  cpp_test_2                          0x000000010435a53c _ZN8module_aC1ERN5flecs5worldE + 52
13  cpp_test_2                          0x000000010435a474 _ZN5flecs7emplaceI8module_aJRNS_5worldEELi0EEEvP11ecs_world_tyyDpOT0_ + 348
14  cpp_test_2                          0x0000000104359664 _ZNK5flecs5world7emplaceI8module_aJRS0_EEEvDpOT0_ + 80
15  cpp_test_2                          0x00000001043591b8 _ZN5flecs1_9do_importI8module_aEEyRNS_5worldEPKc + 216
16  cpp_test_2                          0x0000000104358d74 _ZN5flecs1_6importI8module_aEENS_6entityERNS_5worldE + 156
17  cpp_test_2                          0x0000000104330248 _ZN5flecs5world6importI8module_aEENS_6entityEv + 40
18  cpp_test_2                          0x0000000104330128 main + 52
19  dyld                                0x0000000194cfc274 start + 2840

@Reddy-dev
Copy link
Contributor

Running the above code does give me the assert:

fatal: flecs.c: 21099: assert: type_name[0] == ':' invalid C++ type name (INVALID_PARAMETER)
1   cpp_test_2                          0x000000010439aea8 flecs_log_msg + 1676
2   cpp_test_2                          0x00000001043c3954 ecs_printv_ + 212
3   cpp_test_2                          0x0000000104370988 ecs_log_ + 116
4   cpp_test_2                          0x0000000104363ddc ecs_assert_log_ + 184
5   cpp_test_2                          0x00000001043bd59c ecs_cpp_trim_module + 408
6   cpp_test_2                          0x00000001043bddc4 ecs_cpp_component_register + 388
7   cpp_test_2                          0x000000010435ac9c _ZN5flecs1_9type_implI18module_a_componentE11register_idEP11ecs_world_tPKcbybbS7_y + 648
8   cpp_test_2                          0x000000010435a8d4 _ZN5flecs9componentI18module_a_componentEC2EP11ecs_world_tPKcby + 480
9   cpp_test_2                          0x000000010435a6c0 _ZN5flecs9componentI18module_a_componentEC1EP11ecs_world_tPKcby + 88
10  cpp_test_2                          0x000000010435a620 _ZNK5flecs5world9componentI18module_a_componentJEEENS_9componentIT_EEDpOT0_ + 64
11  cpp_test_2                          0x000000010435a5a4 _ZN8module_aC2ERN5flecs5worldE + 52
12  cpp_test_2                          0x000000010435a53c _ZN8module_aC1ERN5flecs5worldE + 52
13  cpp_test_2                          0x000000010435a474 _ZN5flecs7emplaceI8module_aJRNS_5worldEELi0EEEvP11ecs_world_tyyDpOT0_ + 348
14  cpp_test_2                          0x0000000104359664 _ZNK5flecs5world7emplaceI8module_aJRS0_EEEvDpOT0_ + 80
15  cpp_test_2                          0x00000001043591b8 _ZN5flecs1_9do_importI8module_aEEyRNS_5worldEPKc + 216
16  cpp_test_2                          0x0000000104358d74 _ZN5flecs1_6importI8module_aEENS_6entityERNS_5worldE + 156
17  cpp_test_2                          0x0000000104330248 _ZN5flecs5world6importI8module_aEENS_6entityEv + 40
18  cpp_test_2                          0x0000000104330128 main + 52
19  dyld                                0x0000000194cfc274 start + 2840

what's the major difference between my test push/pull request and the example?

@SanderMertens
Copy link
Owner

I don't know, I haven't looked at the test :) If you want to find out, try copying the code from the issue, and convert it line by line to your test.

@Reddy-dev
Copy link
Contributor

I don't know, I haven't looked at the test :) If you want to find out, try copying the code from the issue, and convert it line by line to your test.

ahh yep messed up the test code now it fails as intended

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

3 participants