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

Cannot Bulk Spawn in a System #837

Closed
deus369 opened this issue Oct 12, 2022 · 3 comments
Closed

Cannot Bulk Spawn in a System #837

deus369 opened this issue Oct 12, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@deus369
Copy link

deus369 commented Oct 12, 2022

Describe the bug
A memory crash when calling ecs_bulk_init within a system.

To Reproduce
Run this script:
https://github.com/deus369/open-zoxel/blob/master/Tests/test_bulk_spawn.c

Expected behavior
No crashy!

Additional context
Ubuntu, amd cpu x86 64 bit..!

@deus369 deus369 added the bug Something isn't working label Oct 12, 2022
@SanderMertens
Copy link
Owner

The ecs_bulk_init operation cannot be called from regular systems. The reason for this is that the operation would have to be executed as command, but the resources passed to the function go out of scope after the system is called. This would require the operation to allocate temporary memory which is slow.

Maybe I'll find a way to support this in the future, but for now it's not possible. I added an INVALID_PARAMETER error that is thrown when you try to call it from a system, so you don't get unexpected crashes.

@deus369
Copy link
Author

deus369 commented Dec 8, 2022

Hi Sander, I think this issue regressed. I am getting a crash on my test!

https://codeberg.org/deus/zoxel/src/branch/master/tests/flecs/bulk_spawn.c

Process terminating with default action of signal 6 (SIGABRT)
==60905== at 0x490926B: __pthread_kill_implementation (pthread_kill.c:44)
==60905== by 0x490926B: __pthread_kill_internal (pthread_kill.c:78)
==60905== by 0x490926B: pthread_kill@@GLIBC_2.34 (pthread_kill.c:89)
==60905== by 0x48B2C45: raise (raise.c:26)
==60905== by 0x48997FB: abort (abort.c:79)
==60905== by 0x489971A: __assert_fail_base.cold (assert.c:92)
==60905== by 0x48AA595: __assert_fail (assert.c:101)
==60905== by 0x115A99: _ecs_poly_assert (in /home/deus/zoxel/tests/builds/bulk_spawn)
==60905== by 0x11C1B9: ecs_bulk_init (in /home/deus/zoxel/tests/builds/bulk_spawn)
==60905== by 0x1BECC5: SpawnSystem (in /home/deus/zoxel/tests/builds/bulk_spawn)
==60905== by 0x1720B7: ecs_run_intern (in /home/deus/zoxel/tests/builds/bulk_spawn)
==60905== by 0x13D225: flecs_run_pipeline (in /home/deus/zoxel/tests/builds/bulk_spawn)
==60905== by 0x13AF22: flecs_workers_progress (in /home/deus/zoxel/tests/builds/bulk_spawn)
==60905== by 0x13CF81: flecs_run_pipeline (in /home/deus/zoxel/tests/builds/bulk_spawn)

@SanderMertens
Copy link
Owner

Maybe I'll find a way to support this in the future, but for now it's not possible

The assert you're getting is the one I added to make sure you don't get silent failures or segfaults.

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