Mysterious crash bug

I have discovered a very strange crash that I have been unable to narrow down to a specific engine feature, but it seems to all be related to the character somehow.

Repro steps:

  1. Download and open the repro file:
    crash-escmenu-repro-minimal.rbxl (98.9 KB)
  2. Start a full playtest
  3. Wait a few seconds. Eventually, a red, flashing, 3D model of the word “ERROR” will be equipped to your character’s right hand to show when you can trigger the bug
  4. Press the Escape key or whatever key you use to open the Roblox escape menu

Expected behavior:
The escape menu opens, no shenanigans.

Actual behavior:
The engine crashes the instant Escape is pressed.

This appears to occur due to the following code:

local function BoundFunctionProxy(ActionName: string, ActionState: Enum.UserInputState, InputObject: InputObject)
	if ActionState == Enum.UserInputState.Cancel then
			
		warn(`Mutating the input state for {ActionName}!`)
			
		ActionState = Enum.UserInputState.End
	end

	local ActionResult: Enum.ContextActionResult? = BoundFunction(ActionName, ActionState, InputObject)

	if not ActionResult then
		return Enum.ContextActionResult.Pass
	else
			
		return ActionResult
	end
end

, in the ModuleScript ReplicatedStorage.SharedModules.ButtonControlsUtility. Removing the line ActionState = Enum.UserInputState.End in the if-statement that checks if ActionState is Cancel (which appears to be triggered when the Escape menu is opened), fixes the crash.

I sincerely apologize that the repro file is… a little hefty. I tried to and have reduced it significantly, but after multiple hours of attempts to reduce it further, I figure that’s it probably not worth it and (hopefully) won’t make that much of a difference in this case.

Main points:

  • A ContextActionService wrapper is used
  • ControllerManagers are used with a Luau state machine (StarterPlayer.StarterCharacterScripts.ControllerStateMachine) and Luau character initialization script (ServerScriptService.InitializeCharacters)
  • All bound functions are related to the character in some way
  • All bound functions are mis-fired at the same time (because the Cancel state is called on all of them regardless of whether their input was ever fired)
  • Some of the code isn’t very good because I’ve haphazardly removed large swathes of it and the datamodel, and some of it was just bad when I first wrote it anyway or has become obsolete
  • The action happens in the ReplicatedStorage.SharedModules.ClientModule ModuleScript and the ServerScriptService.ServerWeapons Script

Workaround: In my case, just don’t change ActionState.

Beta features: Disabling them all changes nothing; the crash still occurs.

3 Likes

Could you show a video of this bug?

2 Likes

I’m sorry for not making it clear - that part is an intentional feature. It’s just a blank weapon that gets equipped that looks like the Source Engine “ERROR” model. It shows when the client scripts have initialized and connected all the functions so you can know when to open the Escape menu.

1 Like

This is just an acknowledgment announcement!

We’ve filed a ticket into our internal database for this issue, and will come back as soon as we have updates!

Thanks for flagging!

1 Like

A fix for this is coming to the next client release. The issue was the how you recursively unbound the controls when entering the menu.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.