Infinite loop with ContextActionService causes client to crash

Steps to reproduce:

Open an empty baseplate, put a local script in StarterGui and create a loop with ContextActionService. Here’s the code I used:

print("Script Began")

function theFunction()
	print("Pressed B")
	game:GetService("ContextActionService"):UnbindAction("Test Action")
	game:GetService("ContextActionService"):BindAction("Other Action", otherFunction, false, Enum.KeyCode.B)
end

function otherFunction()
	print("Pressed B a second time!")
	game:GetService("ContextActionService"):UnbindAction("Other Action")
	game:GetService("ContextActionService"):BindAction("Test Action", theFunction, false, Enum.KeyCode.B)
end

game:GetService("ContextActionService"):BindAction("Test Action", theFunction, false, Enum.KeyCode.B)

Solo Play test in studio, or publish the game and play it. Client crashes in both cases.

Here’s a video demonstration:

Here’s a place file:
ContextActionService Crash Bug Place.rbxl (55.5 KB)

Here’s my system information:
CPU: 11th Gen Intel(R) Core™ i9-11900K @ 3.50GHz
Memory: 32GB
GPU: AMD Radeon RX 5600 XT

Expected behavior

Normally, an infinite loop would exhaust the allowed script execution time.

image

This output was created using this code:

game:GetService("ContextActionService"):BindAction(
	"test",
	function()
		while true do print("b test") end
	end,
	false,
	Enum.KeyCode.B
)
2 Likes