Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong write-past-end error when using append fields #1964

Open
Fusioon opened this issue Apr 29, 2024 · 0 comments
Open

Wrong write-past-end error when using append fields #1964

Fusioon opened this issue Apr 29, 2024 · 0 comments

Comments

@Fusioon
Copy link
Contributor

Fusioon commented Apr 29, 2024

Code to reproduce:

class Program
{
	class Hash
	{
		int8 _codec;

		uint8[] _hash ~ delete:append _;
		public Span<uint8> Hash => _hash;

		public int Length => _hash.Count;

		[AllowAppend]
		public this(Span<uint8> data) 
		{
			let tmp = append uint8[data.Length];

			_hash = tmp;
			data.CopyTo(this._hash);
		}
	}

	class CID
	{
		Hash _mhash ~ delete:append _;

		[AllowAppend]
		public this()
		{
			uint8[32] data = .();
			Hash hash = append .(data);
			this._mhash = hash;
		}

	}

	static void Main()
	{
		CID cid = new .();
		delete cid;
	}
}

Result:
Memory deallocation detected write-past-end error in 101-byte object allocation

Just to note if int8 _codec; is removed the code works as expected.

Tested with: (Nightly 04/28/2024) Build aa4f9f7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant