Attempt to access deleted object with static append field
The issue happens due to the extension defining another append field, if the field in extension is not append its without issues
Code to reproduce:
static class Foo
{
internal static append String s_ContentPath;
public static StringView ContentPath => s_ContentPath;
public static void Set(StringView resourcePath)
{
s_ContentPath.Set(resourcePath); // Error at runtime "Attempted to access deleted object"
}
}
extension Foo
{
internal static append String extPath;
}
class Program
{
static void Main()
{
Foo.Set("bar");
Console.WriteLine(Foo.ContentPath);
}
}
Tested with: (Nightly 10/28/2022)
It's probably not issue with extensions, defining multiple static append fields seems to do the same
Code
static class Foo
{
internal static append String s_ContentPath;
internal static append String s_ContentPath1;
internal static append String s_ContentPath2;
public static StringView ContentPath => s_ContentPath;
public static void Set(StringView resourcePath)
{
s_ContentPath.Set(resourcePath);
s_ContentPath1.Set(resourcePath);
s_ContentPath2.Set(resourcePath);
}
}
class Program
{
static void Main()
{
Foo.Set("bar");
Console.WriteLine(Foo.ContentPath);
}
}
On latest nigthly (https://github.com/beefytech/Beef/commit/7b29a4facb656eb5d6a87526e2b8a60b2128be42) this is still an issue. I've prepared a ready-for-testing project, that is slightly different: bug.1750.zip
What I've noticed, is that:
- This issue happens only when text is long enough;
- EAV happens AFTER we exit
Main(), not insideString.Set(...);
Here is the code inside the project:
namespace bug1750;
using System;
using System.Diagnostics;
static class Foo
{
internal static append String sFirst;
internal static append String sSecond;
internal static append String sThird;
static public StringView sValue => Self.sFirst;
static public void Set (StringView value)
{
Self.sThird.Set(value);
Self.sSecond.Set(value);
Self.sFirst.Set(value);
}
}
class Program
{
static void Main()
{
// This works fine
Foo.Set("123456789");
// But this will trigger EAV
Foo.Set("1234567890");
}
}
Also, this issue exhibits the same thing as in #1216, where DbgVis is failing to view variable state.
static public void Set (StringView value)
{
// Place breakpoint here and hover mouse cursor over 'value' argument.
Self.sThird.Set(value);
Self.sSecond.Set(value);
Self.sFirst.Set(value);
}
Fixed at ec34aa3d43056edc50d3600fa61c3ebfdb72f924