An infinite while loop with SetTimeout causing Operating System(Linux) to Crash
What happened?
- Used the following code
CreateThread(function()
while true do
SetTimeout(1, function()
-- do something here, I called a function when doing it
end)
end
end)
- OS Ram spikes to 100% almost immediately
- Device crashes and requires reboot
Expected result
FXServer / TXadmin to catch the issue and terminate before this happens. If using an infinite while loop without SetTimeout, FXServer reboots.
Reproduction steps
Run the following in a server script
CreateThread(function()
while true do
SetTimeout(1, function()
-- do something here, I called a function when doing it
end)
end
end)
Importancy
Crash
Area(s)
FXServer
Specific version(s)
FiveM b14158
Additional information
No response
Error 40 detected
This doesn't seem like an actual issue, you're infinitely looping, this would be expected behavior.
It's more curious that you managed to actually crash your system running this, since most machines should handle something like this pretty well (for Linux when it got close to maxing out the memory it OOM killed it)
This doesn't seem like an actual issue, you're infinitely looping, this would be expected behavior.
It's more curious that you managed to actually crash your system running this, since most machines should handle something like this pretty well (for Linux when it got close to maxing out the memory it OOM killed it)
I'm only reporting it because it caused an OS crash. Considering FXServer just reboots when using an infinite while loop, I would expect it not doing the same for SetTimeout is a bug
The OS crashing is from you running out of memory, not from something that FXServer is doing, so I still don't think this is an Cfx issue, more-so an issue with how your OS is handling a process using too much memory. As said before on Linux this reproduction will use a lot of ram and max out the CPU core, but when it uses too much memory the Linux OOM killer, kills the process.