trying to make a mod, accidentally crashed my whole computer

Place to get help with not working mods / modding interface.
User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: trying to make a mod, accidentally crashed my whole computer

Post by prg »

So this is not a bug report (since the bug is not in Factorio) but a feature request to add a kludge to work around broken OSes and replicate some of the kernel's functionality to know how much memory can safely be requested in a given situation (just a hardcoded percentage of total RAM won't work too well, this needs to depend on how much other processes are already using).
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

Divran
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Wed Jan 14, 2015 9:13 pm
Contact:

Re: trying to make a mod, accidentally crashed my whole computer

Post by Divran »

prg wrote:So this is not a bug report (since the bug is not in Factorio) but a feature request to add a kludge to work around broken OSes and replicate some of the kernel's functionality to know how much memory can safely be requested in a given situation (just a hardcoded percentage of total RAM won't work too well, this needs to depend on how much other processes are already using).
It was a bug report from the beginning. It would be a feature request if Factorio didn't have a memory check at all, but it does. It just doesn't work properly. If it did, I wouldn't be able to crash my own computer.
Also, I've said this several times, but Garry's Mod is a good example of where this already works. Gmod will stop itself before using too much memory, and it doesn't wait until you're completely out of memory. It sets its own limits afaik. I've no idea how it does it, though. Factorio could probably use the same method.

Anyway, I've only been asked about 4-5 original questions in this entire thread. The rest have just been people repeating the same questions, forcing me to repeat my answers. I'm sick of it now. From now on, unless someone asks a new question, I'm not even going to bother replying. I'm going to wait for a developer to render final judgement on this thread.

Before I go, let me post a status update here:

Facts:
  • I've been able to reproduce the issue three times, on two different sets of hardware. Both computers were running windows 10 home 64bit. I've also reproduced it once in linux, but there the OS stepped in and prevented a total crash.
  • Two other people have tried it and both were unable to reproduce it. No one knows why.
  • Other games have already solved this issue. Garry's Mod is a good example, since it's the same in the sense that it also has lua modding. Where Factorio's memory check seems to trigger when the OS tells Factorio that it's out of memory, Garry's mod's memory check is different. I believe the Source engine sets its own limit somehow, which means it will never even come close to using all of your memory before it stops itself. Perhaps Factorio can use the same method?
Guesstimations:
  • At first, it seemed like Factorio alone was the cause of the crashes, but now I think that isn't entirely true. Factorio uses all of your ram, and then when you attempt to open another app (or even click a button in the windows UI), you no longer have enough memory to perform the action, and since Windows apparently is stupid as a rock, it crashes itself instead of terminating the Factorio process to clear up memory. So, while Factorio allows for it to happen, the blame is much more on Microsoft's head. We probably can't get them to fix it, though.
Last edited by Divran on Fri May 27, 2016 1:27 pm, edited 1 time in total.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: trying to make a mod, accidentally crashed my whole computer

Post by Rseding91 »

Divran wrote:... I'm going to wait for a developer to render final judgement on this thread.
Rseding91 wrote:We're not going to spend time working on trying to prevent mods from making infinite loops.
I already did.
If you want to get ahold of me I'm almost always on Discord.

Divran
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Wed Jan 14, 2015 9:13 pm
Contact:

Re: trying to make a mod, accidentally crashed my whole computer

Post by Divran »

Well that sure is some judgement, but, if this issue is real, it's pretty naive and it's going to come back to bite you. But if that's the way you want to go *shrugs*

EDIT: oh and this issue was never about infinite loops (this is like the 4th time I say this. God damnit I promised myself to not repeat myself)
inb4 someone asks "what is it about then" when I've already answered that many times as well
inb4 someone asks "why is it naive" or "how is it going to bite us" when I've already answered that many times

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: trying to make a mod, accidentally crashed my whole computer

Post by prg »

Divran wrote:
prg wrote:So this is not a bug report (since the bug is not in Factorio) but a feature request to add a kludge to work around broken OSes and replicate some of the kernel's functionality to know how much memory can safely be requested in a given situation (just a hardcoded percentage of total RAM won't work too well, this needs to depend on how much other processes are already using).
It was a bug report from the beginning. It would be a feature request if Factorio didn't have a memory check at all, but it does. It just doesn't work properly. If it did, I wouldn't be able to crash my own computer.
As far as I can see, the check Factorio is doing is working fine. So Factorio is requesting memory from the system. Two things can happen:
  1. It works.
  2. It does not work.
In case of 2, Factorio already properly displays an error message. I don't see any evidence there are currently any additional half-working checks in place in case 1 happens that would cause Factorio to stop requesting memory on its own.
Divran wrote:Also, I've said this several times, but Garry's Mod is a good example of where this already works. Gmod will stop itself before using too much memory, and it doesn't wait until you're completely out of memory. It sets its own limits afaik. I've no idea how it does it, though. Factorio could probably use the same method.
Now we're in feature request territory.
Divran wrote:Anyway, I've only been asked about 4-5 original questions in this entire thread. The rest have just been people repeating the same questions, forcing me to repeat my answers. I'm sick of it now. From now on, unless someone asks a new question, I'm not even going to bother replying. I'm going to wait for a developer to render final judgement on this thread.
I share that feeling.
Divran wrote:Before I go, let me post a status update here:

Facts:
  • I've been able to reproduce the issue three times, on two different sets of hardware. Both computers were running windows 10 home 64bit. I've also reproduced it once in linux, but there the OS stepped in and prevented a total crash.
On Linux with memory overcommitting enabled Factorio never saw an allocation failure so there was nothing it could have done before it was killed. And for the third time: this can be easily prevented by configuring the kernel not to overcommit memory, giving Factorio the opportunity to handle the out of memory condition which it does just fine. Also, the kernel terminating a process is a slightly different issue than the system rebooting.
Divran wrote:
  • Two other people have tried it and both were unable to reproduce it. No one knows why.
  • Other games have already solved this issue. Garry's Mod is a good example, since it's the same in the sense that it also has lua modding. Where Factorio's memory check seems to trigger when the OS tells Factorio that it's out of memory, Garry's mod's memory check is different. I believe the Source engine sets its own limit somehow, which means it will never even come close to using all of your memory before it stops itself. Perhaps Factorio can use the same method?
Every memory allocation has to be checked for success. There doesn't seem to be anything more fancy in Factorio than "if allocation fails, display error message", which is working fine. Anything that Garry's Mod might be doing would be an addition to that check, not a fix of it.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

bNarFProfCrazy
Fast Inserter
Fast Inserter
Posts: 194
Joined: Sat Apr 23, 2016 7:11 am
Contact:

Re: trying to make a mod, accidentally crashed my whole computer

Post by bNarFProfCrazy »

The devs already stated that the wont do anything about it. So we can just stop the discussion here.

Divran
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Wed Jan 14, 2015 9:13 pm
Contact:

Re: trying to make a mod, accidentally crashed my whole computer

Post by Divran »

prg you keep saying the check already works, but then why was I able to reproduce it on two different computers? I agree with everything else you said in your latest post though

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: trying to make a mod, accidentally crashed my whole computer

Post by prg »

Divran wrote:prg you keep saying the check already works, but then why was I able to reproduce it on two different computers? I agree with everything else you said in your latest post though
Here's how you allocate memory:

Code: Select all

Request x bytes of memory from the system
Was there an error? {
    Possibly inform the user
    Stop what you're doing and return with an error status
}
Use newly allocated memory
Now if the "was there an error" part wasn't done correctly and the process tried to use the newly allocated memory which isn't actually there, it would simply die with a segmentation fault. In C++ you could use operator new for the "request memory" part which would throw a bad_alloc exception to force you into the error handling branch so you wouldn't even get to try to use the memory. Then the process would die with an uncaught exception if you didn't take care of that properly.

In any case the process would be dead and the rest of the system still alive. But we've never seen the Factorio process itself crash because of an out of memory condition. So what you're seeing must be that the whole system dies before the kernel starts denying memory allocations to Factorio. In that case you'd need to add some psychic abilities to Factorio so it knows when to stop requesting memory before the system tells it to.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

Divran
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Wed Jan 14, 2015 9:13 pm
Contact:

Re: trying to make a mod, accidentally crashed my whole computer

Post by Divran »

In other words, like we both have already said earlier, this is technically windows' fault. Until microsoft fixes it (aka never), Factorio can't use a hard cap to the amount of memory it gives itself because... reasons?

User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: trying to make a mod, accidentally crashed my whole computer

Post by prg »

Divran wrote:In other words, like we both have already said earlier, this is technically windows' fault. Until microsoft fixes it (aka never), Factorio can't use a hard cap to the amount of memory it gives itself because... reasons?
Huh? Where did I say adding such a limit would not be possible? It just wouldn't fix existing functionality but be an additional safety measure. It's questionable whether adding a rarely needed workaround for broken OSes is worth the development time. Seems like the devs decided it isn't. End of story.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

Divran
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Wed Jan 14, 2015 9:13 pm
Contact:

Re: trying to make a mod, accidentally crashed my whole computer

Post by Divran »

Alright then I guess this thread is over. It's all microsoft's fault so the only question is whether to ask them to fix it now or wait until problems start happening and ask them then.

/thread

EDIT: and also HOW do we ask them to fix it? There doesn't appear to be any good place to post such a request. eh whatever don't have time to go looking for that

Post Reply

Return to “Modding help”