CreateVirtualEntity: Attempted to read or write protected memory
vanlueckn opened this issue · comments
Nils van Lück commented
Server Version: alt:V RC 3
Nuget: alt:V RC 6
The server crashes with this exception when i try to create a virtual entity:
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at AltV.Net.Core.CreateVirtualEntity(AltV.Net.Elements.Entities.IVirtualEntityGroup, AltV.Net.Data.Position, UInt32, System.Collections.Generic.Dictionary`2<System.String,System.Object>)
at AltV.Net.Alt.CreateVirtualEntity(AltV.Net.Elements.Entities.IVirtualEntityGroup, AltV.Net.Data.Position, UInt32, System.Collections.Generic.Dictionary`2<System.String,System.Object>)
at PlusOne.Script.Fire.FireSystem.CreateFire(AltV.Net.Data.Position, Boolean, Int32, Int32)
at System.RuntimeMethodHandle.InvokeMethod(System.Object, Void**, System.Signature, Boolean)
at System.Reflection.MethodInvoker.Invoke(System.Object, IntPtr*, System.Reflection.BindingFlags)
at System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
at System.Delegate.DynamicInvokeImpl(System.Object[])
at AltV.Net.Function.Call(AltV.Net.Elements.Args.MValueConst[])
at AltV.Net.Core.OnServerEvent(System.String, IntPtr[])
at AltV.Net.ModuleWrapper.OnServerEvent(System.String, IntPtr, UInt64)
C# Code:
var entity =
Alt.CreateVirtualEntity(FireGroup, position, 200, (Dictionary<string, object>) fireData.ToDictionary());
entity.Dimension = DimensionOffsetService.Get(DimensionOffsetEnum.Default);
Variable dump:
FireGroup: AsyncVirtualEntityGroup (not null)
Position: (0, 0, 0) as Position
fireData: Dictionary with different values (not null)
Till Schreiber commented
Cannot repo it
var group = Alt.CreateVirtualEntityGroup(29);
var data = new Dictionary<string, object>();
data.Add("test", "test");
var entity = Alt.CreateVirtualEntity(group, new Position(0, 0, 0), 200, data);
Nils van Lück commented
I checked it. The error only appears if the dictionary contains a null
value. This was possible in v14 and now a crash occurs.
Example:
var group = Alt.CreateVirtualEntityGroup(29);
var data = new Dictionary<string, object>();
data.Add("test", null);
var entity = Alt.CreateVirtualEntity(group, new Position(0, 0, 0), 200, data);
Till Schreiber commented
Its fixed!