Crash when inserting / deleting instances with extremely long ancestry

Here’s a snippet that will create an unreasonable amount of folders parented in a chain:

local timeout = os.clock() + 1/60
local a = workspace
for i = 8192, 1, -1 do
	local b = Instance.new("Folder")
	b.Name = i
	b.Parent = a
	a = b
	if os.clock() > timeout then -- Prevent freezing
		print("Progress", i)
		game:GetService("RunService").Heartbeat:Wait()
		timeout = os.clock() + 1/60
	end
end
print("Done")

I was deciding if I should design something so I iterate through objects in a parent chain like that so I came up with that command to test the limitations. The idea is that FindFirstChild needs to search through every child, but the search scales a lot better if it’s daisy chained like that. Anways, it doesn’t always crash the first time, but entering the command multiple times always causes a crash for me.
image

Game servers handle it incredibly well in comparison:
image

I’ve also had it happen when deleting one of the folder groups.

This is a bit random, but a crash is a crash. I can send the memory dump if needed.


If anyone’s curious, I’m trying to get around the StringValue.Value data size limitation of 199999 bytes in a way that works with ChangeHistoryService.

My first design was like this, but multiple instances had to be parented to nil when the string’s length is shortened:
image

With this chained design, I just need to parent the first extra child to nil when the string’s length is shortened. Plus FindFirstChild is a tiny bit faster and there’s no need to convert numbers to strings. I could also add other numbered children to the value if needed. It’s just a simpler implementation overall:
image

I’m a little bit afraid of how DescendantAdded needs to be updated for the entire chain, so I’m still not sure. Nearly all of my chunks of data will be well under 200000 bytes, but I don’t want to get hit with confusing errors randomly in the future.

3 Likes

Thanks for the report! We’ve filed this internally and we’ll follow up here when we have an update for you.

1 Like

Hi there, thanks for filing this bug report. Unfortunately, fixing it isn’t currently on the roadmap. The engineers have stated “that after using studio for a while the undo stack keeps growing unbounded, and if you try to do a large operation there might not be enough memory left to add the undo operation. Trying to cap this is not feasible at this time.” so we can’t prioritize a fix at this time. Thank you for filing this issue.

3 Likes