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

Closed
Fusioon opened this issue Apr 29, 2024 · 1 comment
Closed

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

Fusioon opened this issue Apr 29, 2024 · 1 comment

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

@kallisto56
Copy link
Contributor

On latest nightly (439ae8d) this is no longer an issue. I believe that recent fix to append resolved that.

On one of the older builds I have, this does happen:

FATAL ERROR
Memory deallocation detected write-past-end error in 101-byte object allocation at 0xBF0'110200E0 in C:\Beef\BeefRT\dbg\gc.cpp:982

@bfiete bfiete closed this as completed Jan 31, 2025
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

3 participants