Search Issue Tracker

Fixed in 0.14.0

Votes

0

Found in [Package]

0.8.0 - preview.8

Issue ID

1262093

Regression

Yes

Crash when calling EntityManager.CreateEntity(new EntityArchetype(), 1, Allocator.Temp)

Package: Entity Component System (ECS)

-

How to reproduce:
1. Open attached project "Case_1262093"
2. Press Play

Reproducible with: Entities: 0.8.0 - preview.8, 0.11.1 - preview.4(2019.4.4f1, 2020.1.0b16, 2020.2.0a18)
Not reproducible with: Entities: 0.0.12 - preview.24 (2018.4.25f1), 0.7.0 - preview.19 (2019.4.4f1, 2020.1.0b16, 2020.2.0a18)

First lines of the stack trace:
0x00007ffec523103e (592a0d624a81e04423678b58ab5bbc5) 24CFDDDB6D7CECAC
0x000001f7b58b83f4 (Mono JIT Code) (wrapper managed-to-native) object:wrapper_native_000001F7AD550160 (Unity.Entities.EntityComponentStore*,void*,Unity.Entities.Entity*,int)
0x000001f958d59f74 (Mono JIT Code) [EntityManagerChangeArchetype.interop.gen.cs:368] Unity.Entities.StructuralChange:_forward_mono_CreateEntity (Unity.Entities.EntityComponentStore*,void*,Unity.Entities.Entity*,int)
0x000001f958d59ec3 (Mono JIT Code) [EntityManagerChangeArchetype.interop.gen.cs:350] Unity.Entities.StructuralChange:CreateEntity (Unity.Entities.EntityComponentStore*,void*,Unity.Entities.Entity*,int)
0x000001f958d59e23 (Mono JIT Code) [EntityDataAccess.cs:490] Unity.Entities.EntityDataAccess:CreateEntity (Unity.Entities.EntityArchetype,Unity.Entities.Entity*,int)

Notes:
1. Does not reproduce with Burst Compilation disabled
2. Sometimes crashes instantly, other times you need to wait in Play Mode for the crash to occur

  1. Resolution Note (fix version 0.14.0):

    Fixed in: Entities 0.14.0 - preview.18

    The root issue here is that `new EntityArchetype()` returns an invalid value that you're not supposed to use. To get valid EntityArchetype values, you must call `EntityManager.CreateArchetype()` instead.

    We unfortunately can't stop you from instantiating invalid values because a struct's default constructor cannot be overridden or hidden.

    So our fix is that safety checks in CreateEntity() and SetArchetype() will now throw an exception if you pass the invalid EntityArchetype value.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.