Roblox crashes when a function inside a modulescript is called from outside the modulescript and the function inside the modulescript errors while returning.
Edit: This crash is caused by “Unprotected call to Lua API (attempt to index a nil value)” in all cases I’ve seen on my computer. Which the provided code and model cause.
Reproduction model: http://www.roblox.com/Roblox-Crash-item?id=160885668
Example:
Main script:
local runModule = require(script.Module)
runModule()
Module:
[code]local causeError = function()
error()
end
returnFunction = function()
return causeError()
end
return returnFunction[/code]
No crash will occur if returnFunction is not called from a separate script or module.
No crash occurred when I tested this over _G instead of from a required modulescript.
No crash will occur if causeError() is replaced with error()
No crash will occur if the module is required from the commandbar.
No crash will occur if returnFunction attempts to put the result of causeError() in a variable before returning. Instead, an error is thrown as it should be.
A crash will still occur if causeError is passed in or loaded from anywhere else.
A crash will still occur if returnFunction is called from any other script or module after being required.
A crash will still occur if causeError causes a different error. (This originally occurred with a “Attempt to index name (a nil value)” error)
A crash still occurred in a new place with all plugins deleted on both the website and in my plugins folder.
A crash does not appear to occur on all computers!
Seranok tested this and did not crash, but instead got an error (the expected result).
Edit: Pyrolysis got a crash.
Edit If I add some wait(0.5)s to the script I’m able to see the error it produces.
I believe that this crash is broader than what is described here, but I’m not sure how to reproduce it. This error happened when several functions within separate modulescripts were called from outside of the original modulescript (occasionally in a completely separate modulescript) and an error occured within one of them.
Image of the new error:
This error also occurred when I tried to get MarketPlaceService.