Upgrading to Unity.Burst 1.3.4 causes System.InvalidOperationException: Unable to create a SharedSta

Today I tried to update some of the dots packages, in particular com.unity.burst 1.3.3 => 1.3.4 seems to cause this exception, but I did noot have the time ot dig deeper

Unexpected exception System.InvalidOperationException: System.InvalidOperationException: Unable to create a SharedStatic for this key. It is likely that the same key was used to allocate a shared memory with a smaller size while the new size requested is bigger
Thrown from job: Unity.Entities.StructuralChange._mono_to_burst_RemoveComponentEntitiesBatch
This Exception was thrown from a function compiled with Burst, which has limited exception support. Turn off burst (Jobs -> Burst -> Enable Compilation) to inspect full exceptions & stacktraces.
  at (wrapper managed-to-native) System.Object.wrapper_native_00007FFF92C5AA30(Burst.Compiler.IL.Jit.JitBurstInitializeUtility/ResolveExternalFunctionDelegate)
  at Burst.Compiler.IL.Jit.JitBurstInitializeUtility.InvokeBurstInitializeFunction (System.IntPtr initFunctionPointer, System.Collections.Generic.List`1[T] externalFunctions) [0x00045] in <12fd8c57ac5741e888f3e2a61ac3563b>:0
  at Burst.Compiler.IL.Jit.JitCompiler.CompileMethodInternal (Burst.Compiler.IL.Jit.JitResult result, System.Collections.Generic.List`1[T] methodsToCompile, Burst.Compiler.IL.Jit.JitOptions jitOptions) [0x00578] in <12fd8c57ac5741e888f3e2a61ac3563b>:0
  at Burst.Compiler.IL.Jit.JitCompiler.CompileMethods (Mono.Cecil.MethodReference[] methodReferences, Burst.Compiler.IL.Jit.JitOptions jitOptions) [0x00271] in <12fd8c57ac5741e888f3e2a61ac3563b>:0
  at Burst.Compiler.IL.Jit.JitCompiler.CompileMethod (Mono.Cecil.MethodReference methodReference, Burst.Compiler.IL.Jit.JitOptions jitOptions) [0x0001c] in <12fd8c57ac5741e888f3e2a61ac3563b>:0
  at Burst.Compiler.IL.Jit.JitCompilerService+CompilerThreadContext.Compile (Burst.Compiler.IL.Jit.JitCompilerService+CompileJob job) [0x003cb] in <12fd8c57ac5741e888f3e2a61ac3563b>:0

While compiling job: System.Void Unity.Entities.StructuralChange::_mono_to_burst_RemoveComponentEntitiesBatch(Unity.Entities.EntityComponentStore*,Unity.Collections.LowLevel.Unsafe.UnsafeList*,System.Int32)
at <empty>:line 0
(Filename:  Line: 0)

What does this exception mean exactly?
Has anyone encountered it?
How can I solve it?

1 Like

Got the same thing today. It looks like 1.3.4 Burst doesn’t work with Entity package.

worked for me rolling back to Burst 1.3.3.

1 Like

Just to rule something easy out - did you restart the editor after doing the Burst update or not?

Yes

1 Like

Got same error. Burst version is 1.3.2

UPD: fixed after i have switched to 1.3.4

I’m now getting this same error after upgrading to Burst 1.3.9.

Unity.Burst.SharedStatic.GetOrCreateSharedStaticInternal (System.Int64 getHashCode64, System.Int64 getSubHashCode64, System.UInt32 sizeOf, System.UInt32 alignment) (at Library/PackageCache/com.unity.burst@1.3.9/Runtime/SharedStatic.cs:160)
Unity.Burst.SharedStatic`1[T].GetOrCreate[TContext] (System.UInt32 alignment) (at Library/PackageCache/com.unity.burst@1.3.9/Runtime/SharedStatic.cs:59)
Unity.Entities.EntityComponentStore..cctor () (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities/EntityComponentStore.cs:1428)
Rethrow as TypeInitializationException: The type initializer for ‘Unity.Entities.EntityComponentStore’ threw an exception.
Unity.Entities.EntityDataAccess.Initialize (Unity.Entities.EntityDataAccess* self, Unity.Entities.World world) (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities/EntityDataAccess.cs:164)
Unity.Entities.EntityManager.Initialize (Unity.Entities.World world) (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities/EntityManager.cs:220)
Unity.Entities.World..ctor (System.String name, Unity.Entities.WorldFlags flags) (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities/World.cs:472)
Unity.Entities.DefaultWorldInitialization.Initialize (System.String defaultWorldName, System.Boolean editorWorld) (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities/DefaultWorldInitialization.cs:127)
Unity.Entities.AutomaticWorldBootstrap.Initialize () (at Library/PackageCache/com.unity.entities@0.14.0-preview.19/Unity.Entities.Hybrid/Injection/AutomaticWorldBootstrap.cs:15)```

Anybody getting this error in 2023 (I upgraded from burst 1.8.7 to 1.8.8)? Restarting the editor did not fix the issue.

EDIT: Found a fix that worked for me: Close the editor. Delete the Project > Library > BurstCache folder. Reopen the editor.

6 Likes