Update DebugSymbols

This commit is contained in:
2025-11-27 15:02:33 +09:00
parent b67569aa14
commit 8f4a2aa5d6
3 changed files with 14 additions and 11 deletions

View File

@@ -58,7 +58,7 @@ public static unsafe class AllocationManager
public AllocationHeader* next; public AllocationHeader* next;
public void* basePtr; // pointer returned by underlying allocator public void* basePtr; // pointer returned by underlying allocator
public nuint userSize; // requested size from the user public nuint userSize; // requested size from the user
public nint stackHandle; // GCHandle to managed StackTrace (stored as IntPtr) public GCHandle stackHandle; // GCHandle to managed StackTrace
} }
private struct ArenaAllocator : IAllocator, IDisposable private struct ArenaAllocator : IAllocator, IDisposable
@@ -270,18 +270,17 @@ public static unsafe class AllocationManager
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private static GCHandle HeaderGetHandle(AllocationHeader* header) => GCHandle.FromIntPtr(header->stackHandle); private static GCHandle HeaderGetHandle(AllocationHeader* header) => header->stackHandle;
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void HeaderSetHandle(AllocationHeader* header, GCHandle handle) => header->stackHandle = GCHandle.ToIntPtr(handle); private static void HeaderSetHandle(AllocationHeader* header, GCHandle handle) => header->stackHandle = handle;
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void HeaderFreeHandle(AllocationHeader* header) private static void HeaderFreeHandle(AllocationHeader* header)
{ {
if (header->stackHandle != 0) if (header->stackHandle.IsAllocated)
{ {
GCHandle.FromIntPtr(header->stackHandle).Free(); header->stackHandle.Free();
header->stackHandle = 0;
} }
} }
@@ -403,7 +402,7 @@ public static unsafe class AllocationManager
} }
// Unlink and free the old block (without freeing the StackTrace pHandle again) // Unlink and free the old block (without freeing the StackTrace pHandle again)
oldHeader->stackHandle = 0; //oldHeader->stackHandle = GCHandle.FromIntPtr(0);
UnlinkHeader(oldHeader); UnlinkHeader(oldHeader);
AlignedFree(oldHeader->basePtr); AlignedFree(oldHeader->basePtr);

View File

@@ -5,8 +5,10 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<DebugSymbols>True</DebugSymbols>
<DebugType>portable</DebugType>
<Authors>Misaki</Authors> <Authors>Misaki</Authors>
<AssemblyVersion>1.2.2</AssemblyVersion> <AssemblyVersion>1.2.3</AssemblyVersion>
<Version>$(AssemblyVersion)</Version> <Version>$(AssemblyVersion)</Version>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild> <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageProjectUrl>https://git.personalnas.com/Misaki/Misaki.HighPerformance.git</PackageProjectUrl> <PackageProjectUrl>https://git.personalnas.com/Misaki/Misaki.HighPerformance.git</PackageProjectUrl>

View File

@@ -40,16 +40,18 @@
// } // }
//} //}
using Misaki.HighPerformance.LowLevel.Buffer;
using Misaki.HighPerformance.LowLevel.Utilities; using Misaki.HighPerformance.LowLevel.Utilities;
AllocationManager.EnableDebugLayer();
var arr1 = new Misaki.HighPerformance.LowLevel.Collections.UnsafeArray<int>(10, Misaki.HighPerformance.LowLevel.Buffer.Allocator.Persistent); var arr1 = new Misaki.HighPerformance.LowLevel.Collections.UnsafeArray<int>(10, Misaki.HighPerformance.LowLevel.Buffer.Allocator.Persistent);
var arr2 = arr1; var arr2 = arr1;
arr2.CopyFrom(arr1.AsSpan()); arr2.CopyFrom(arr1.AsSpan());
arr1.Dispose(); //arr1.Dispose();
try try
{ {
arr2[0] = 42; // This should throw an exception because arr1 has been disposed. arr2[0] = 42; // This should throw an exception because arr1 has been disposed.
arr2.Dispose(); //arr2.Dispose();
AllocationManager.Dispose();
} }
catch (Exception ex) catch (Exception ex)
{ {