This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Lachcim's profile picture

Prevent the startup program from launching when a computer reboots due to crash

Started by Lachcim, 22 January 2016 - 07:49 PM
Lachcim #1
Posted 22 January 2016 - 08:49 PM
Hi,
As you know, when a ComputerCraft computer crashes (i.e. it uses up too much CPU), it reboots. This behavior, however, can be exploited, and that's what I accidentally managed to do today. Basically, I wrote a faulty program containing an infinite loop, named it "startup" and then decided to launch it. As you might have expected, the computer rebooted, but then it ran into the same loop again and again, killing the CPU and making the game unplayable. What's worse, all of it happened in multiplayer mode and now the owner of the server is threatening to remove ComputerCraft from the modpack completely :(/>

My point is, why don't we make it so that when a computer crashes, it doesn't launch the startup program by default? This would prevent exploits and unfortunate accidents, such as the one I had. I realize that such an issue can be easily fixed by fiddling with the save folder, but the owner fears he may not have access to the server files at the time of such accident/attack.

Thanks
Lyqyd #2
Posted 23 January 2016 - 01:18 AM
Computers that go too long without yielding have the offending coroutine or the next lowest possible coroutine killed. That will occasionally cause them to shut down. I have never seen it cause a reboot, unless you have an external program booting computers continuously.

I'd appreciate you posting the code in question.
Lachcim #3
Posted 23 January 2016 - 08:50 AM
Upon closer inspection it appears you're right - they don't actually reboot, it was me booting them up in an attempt to shut them down, which in turn caused more lag than it would have. Welp, I guess I'm stupid, sorry for the inconvenience :P/>
HDeffo #4
Posted 23 January 2016 - 09:42 AM
The trick to situations like this is to have a very simple startup program on a floppy disk and place that next to the computer since disk/startup will run before startup. A simple print message or even a completely blank program will suffice. The problem with overriding startup altogether is mainly in security. Lets take a login program I commonly use on servers as an example. Because I don't trust admins not to look at my programs and I like to store them more cloud based so I have them on all servers I use a login program that communicates directly to my website. The issue is I don't actually have this site on 24/7 and for now (though not the best practice) I'm content with the fact the program causes an error and shuts down when someone tries to log in while my website is down, because then it just reboot right back to the login screen again. If the system suddenly changed someone could just cause an error to break into my computer which defeats part of why I have a login screen in the first place.