Crash by writing in readonly value

This subforum contains all the issues which we already resolved.
Post Reply
Hermios
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Sat Aug 13, 2016 2:57 pm
Contact:

Crash by writing in readonly value

Post by Hermios »

Hi,
I develop a new mod, and trid -by mistake - to write in readonly values (i.e. entity.train and entity.train.status).
As a consequence, instead of displaying a little message, close the current game and let me reload it immediatly, the soft crashed.
Attached the log of the crash.
Thanks
Attachments
crash Factorio.txt
(2.93 KiB) Downloaded 41 times

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

Re: Crash by writing in readonly value

Post by Rseding91 »

It looks like you tried to write to the variables during an event - possibly train created?
If you want to get ahold of me I'm almost always on Discord.

Hermios
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Sat Aug 13, 2016 2:57 pm
Contact:

Re: Crash by writing in readonly value

Post by Hermios »

Hi,
I confirm that my code was wrong. My point is, it shouldn't crash, just display a message. Since, I had other issues, like writing a status of a train, adding an attribute to a LuaEntity that doesn't exist, with the same result: Crash of Factorio, instead of displaying a nice, friendly message and letting me try again.
Said otherwise, Factorio overreacts :)
Thanks

Niko

P.S: The event is raised by a combination of keys, and the purpose is to destroy entities to recreate them with a new picture.

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

Re: Crash by writing in readonly value

Post by Rseding91 »

Yes, it's meant to show an error and put you back on the main menu. However, I'm trying to figure out how it crashed instead. Based off the stack trace in the log file you uploaded I'm speculating your code was running inside of some train related event when it errored?

And as such, it left the train in a partially invalid state and crashed later trying to use the invalid train?
If you want to get ahold of me I'm almost always on Discord.

Hermios
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Sat Aug 13, 2016 2:57 pm
Contact:

Re: Crash by writing in readonly value

Post by Hermios »

Sorry, I misunderstood your point.
I just made a test by removing every other mod related to trains (This one only reacts on combination of keys) and... same crash (In my example, this is because I try to iterate on a nil value). So this has nothing to do with events for trains. However, when this event is raised, a locomotive is destroyed and a new one is created, with my character in it. Besides, when I did the same with other vehicles (tank and car), no such crash.
So it is probably related to trains, at the end of the day.

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

Re: Crash by writing in readonly value

Post by Rseding91 »

Can you upload a simple mod + steps that reproduces the issue?
If you want to get ahold of me I'm almost always on Discord.

Hermios
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Sat Aug 13, 2016 2:57 pm
Contact:

Re: Crash by writing in readonly value

Post by Hermios »

Attached the mod, and my sandbox game.
Just type "SHIFT+I", which triggers the event, and here comes the crash!
Attachments
sandbox_base.zip
(1.92 MiB) Downloaded 46 times
Ninjario_0.1.1.zip
(44.57 KiB) Downloaded 48 times

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

Re: Crash by writing in readonly value

Post by Rseding91 »

Thanks for the save and easy steps to reproduce it. It's now fixed for 0.17.
If you want to get ahold of me I'm almost always on Discord.

Hermios
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Sat Aug 13, 2016 2:57 pm
Contact:

Re: Crash by writing in readonly value

Post by Hermios »

Great, you are aweseome guys!
Thanks

Post Reply

Return to “Resolved Problems and Bugs”