[Lou][1.1.27] Error ElectricPole.cpp:1371: Zero cnnection before non-zero in "..." at { }

This subforum contains all the issues which we already resolved.
User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 419
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

[Lou][1.1.27] Error ElectricPole.cpp:1371: Zero cnnection before non-zero in "..." at { }

Post by Stringweasel »

Hello!

I ran into this hard crash that happens during multiplayer while saving using an unreleased version of my Fluidic Power mod. I'm fairly certain the hard crash is caused by my mod, but I'm under the impression a mod should not easily be able to hard-crash Factorio.

So what happened:
  • Happened while saving. It happened a few times, during an autosave, save-for-joining-player and just a normal escape-save-game.
  • At first I thought it was because we were placing poles just before the autosave, but for the last crash we were deliberately doing nothing.
  • Happened during multiplayer, and is likely the first time this Fluidic Power is used in multiplayer (as far as I know)
  • I've never seen this in my many hours of single-player testing of my mod. I even tried running the multiplayer save in single player, but couldn't get it to crash.
I'll very quickly explain how my Fluidic Power mod works in steady-state, if that helps. All power poles are two entities. On top is an `electric-pole` from which I delete all copper wires on creation (in the name it has a tag at the end `-electric`). This means there are lots of separate electric networks. For 90% of the poles, there is a `generator` entity below them to generate power. The fluidbox of this entity allows the movement of 'power fluid' through the network. There are no on-tick power calculations or anything done with electric poles. Then at the steam engines where power is generated the fluid entity below the power pole is an assembling machine.

Attached is:
  • The log (or previous log)
  • The unreleased Fluidic Power 0.3.3 we played with
  • The save game. There is a couple of minutes of playing between this save and when the crash happened.
  • The savegame *.tmp.zip that was generated during the crashing save operation. (I saw this laying in the save folder after each crash)
I didn't attach the Hall of Fame mod since it's 70MB, but you can just download the latest version here. Thinking back I should've tested it without the Hall of Fame just to be safe, although I highly doubt it would cause a problem.

Please let me know if I missed any information!

Thanks!
Attachments
Walvis Craft - Fluidic.zip
(3.04 MiB) Downloaded 173 times
Walvis Craft - Fluidic.tmp.zip
(1.85 MiB) Downloaded 170 times
FluidicPower_0.3.3.zip
(853.48 KiB) Downloaded 165 times
factorio-previous.log
(16.9 KiB) Downloaded 190 times
User avatar
Lou
Factorio Staff
Factorio Staff
Posts: 192
Joined: Mon Nov 30, 2020 10:50 am
Contact:

Re: [Lou][1.1.27] Error ElectricPole.cpp:1371: Zero cnnection before non-zero in "..." at { }

Post by Lou »

Hello!

Thank you for your feedback. So far I have just superficially looked over the issue and here are some points.

a) As the error suggests, it is caused by having copper connections in ElectricPole in "wrong order", specifically actual connection after nulls. This is (for numerous reasons) considered inconsistent game state -> therefore the crash. In past versions, there were some problems with this due to BPs and stuff, so we added this specific consistency check in the save instead of the normal load to prevent long playtroughs being lost to this. -> therefore crash in save

b) ad "..I'm under the impression a mod should not easily be able to hard-crash Factorio.." It shouldn't :) at least not in this way.

c) If this happens only in multiplayer, and not your singleplayer, I have two hypotheses:
  • either some other player did something you haven't considered - therefore you did not test in in singleplayer.
  • it has to do with latency state
Either way it would help a lot if you have/haven't done before successful/unsuccessful saves. (placing, BPs, ghosts, deconstruction planning, mining, upgrade planning, fast replace, (de)construction by robots, etc.)

d) in fluidic_handle-poles.lua instead of this:

Code: Select all

    
    -- First disconnect his neighbours
    for _, neighbour in ipairs(entity.neighbours["copper"]) do
        if neighbour.name ~= "entity-ghost" then
            neighbour.disconnect_neighbour()
        end
    end

    -- Now disconnect the entity itself from any remaining poles
    entity.disconnect_neighbour()
it should be sufficient to just do this:

Code: Select all

entity.disconnect_neighbour()
It should take care of inverse connections too. If it doesn't, please, let me know.

e) Solving this will have low priority for us (for the time being), so I will not start some deep debugging process anytime soon (unless you provide me with more specific info of what to look for). However, if you are planning to hold more multiplayer sessions with this mod (with the intent of debugging), I could enhance the error log message for the next version.

f) To clarify, did the crash occur in every save or just sometimes?
User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 419
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: [Lou][1.1.27] Error ElectricPole.cpp:1371: Zero cnnection before non-zero in "..." at { }

Post by Stringweasel »

Hello Lou! Thanks for taking the time to look at this.

a) Just to make sure I understand you correctly. There's a list of connections for each pole, and the error would be thrown if the list looks like [NULL, NULL, connection]? You obviously want all connections in the first elements of the list. That does sound like something the `disconnect_neighbours`-function would do, but as far as I know, there should be no connections at all? So a remnant connection is bad.

c) Won't the generated `Walvis Craft - Fluidic.tmp.zip` show you the state of the game that doesn't want to save? Or will simply knowing a state in which it fails does not tell you how it got there? I.e. how the connection list got mixed up. Anyway, I will see if I can get a better way to reproduce the crash.

d) Is this disconnection function a potential main culprit? There are issues with connections, and that's the only time I touch them. Regarding the way I did it: I'm pretty sure I tested it and it didn't work, but turns out it does. I was likely tired and saw the ghosts showing cables, which I can't stop. When the pole is placed the wires disappear as expected. Thanks!

e) I'm definitely going to keep testing. I want to make my mod multiplayer-save. I understand that it's not a high priority for Wube, but extra logging would definitely be helpful. I will also see if I can get you more information so that we can fix this.

f) It didn't seem erratic. Like it would save fine, until one specific point. When I manually saved it mostly worked fine, and when it worked I would spam the save button and it never failed. But then after some time again it would crash on the next save. Sometimes sooner, sometimes later. This does seem to correlate with one of the electric pole's connections getting messed up for some reason.
Alt-F4 Author | Factorio Modder
My Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby
Official Contributor to Space Exploration
User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 419
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: [Lou][1.1.27] Error ElectricPole.cpp:1371: Zero cnnection before non-zero in "..." at { }

Post by Stringweasel »

I figured out the interaction that breaks the saving operation! Or corrupts the pole neighbours. Before this interaction the game saves fine, and after the interaction, the game crashes with the attached log file. You can use the same Fluidic Power mod file I supplied in the initial post.

The interaction:

1. Open save file "Walvis Craft - Fluidic - NEW.zip"
2. Save the game and see it works fine.
3. Get a "Small Electric Pole" in your cursor.
4. Place it in the location shown in the picture below.
5. Attempt to save the game and it will crash.
Image

It's hard to see, but you're basically skipping a ghost in the placement. In the picture, it's the ghost in the middle of the "underground lines", between the two inserters. Don't know if it's relevant.

I tried changing my "disconnect neighbour" code to as you recommended, but the game still crashes.

I'm still digging to see if I can reproduce it from scratch. But at least now we know a case where there are no corrupt pole neighbours, and an action to corrupt it.
Attachments
Walvis Craft - Fluidic - NEW.zip
(3.33 MiB) Downloaded 138 times
factorio-current.log
(9.96 KiB) Downloaded 154 times
Alt-F4 Author | Factorio Modder
My Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby
Official Contributor to Space Exploration
User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 419
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: [Lou][1.1.27] Error ElectricPole.cpp:1371: Zero cnnection before non-zero in "..." at { }

Post by Stringweasel »

Oh, and important, it happens in single-player as well.
Alt-F4 Author | Factorio Modder
My Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby
Official Contributor to Space Exploration
User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 419
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: [Lou][1.1.27] Error ElectricPole.cpp:1371: Zero cnnection before non-zero in "..." at { }

Post by Stringweasel »

Okay, now I can reproduce it from scratch. Before you do this your game can save, afterwards, the save crashes.

Steps to reproduce.
1. Don't be in editor mode, we need to place ghosts. Also no robots, we build by hand.
2. Place 5 modded "Small Electric Poles" in a vertical line, with no spaces between them.
3. Copy the column of poles, and paste the ghosts 7 tiles to the side (left in my example). Each ghost will be connected to each placed pole by copper.
4. Place a pole over the bottom ghost, and the third from the bottom ghost, skipping one.
5. Try to save again, and crash!

Just before you place the pole in Step 4 your setup should look like this (the belts are there to show spacing):
Image

This seems to break the save every time like 90% of the time.

I attached the updated version of my mod with the neighbour disconnect code changed to look as you recommended. This testing was done with this update. Unfortunately, the version number is still 0.3.3. I'm not always good with versioning. :P
Attachments
FluidicPower_0.3.3.zip
(853.81 KiB) Downloaded 154 times
Alt-F4 Author | Factorio Modder
My Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby
Official Contributor to Space Exploration
User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 419
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: [Lou][1.1.27] Error ElectricPole.cpp:1371: Zero cnnection before non-zero in "..." at { }

Post by Stringweasel »

I'm going to shower you with more information with the hope that it makes it easier to fix, and that it becomes worth your time. :lol:

Here are a map and mod with a minimal example to reproduce it foolproof, as well as the created log file. The mod changed a little from when this thread started. I seem to have called the disconnect neighbours functions more than I needed, but after reducing it still crashes in certain instances.

Steps:
1. Download map and mod
2. Open map and mod in single player.
3. Copy the poles from one of the sides placed on the refined concrete.
4. Paste the ghosts on the middle Refined Hazardous Concrete.
5. Place the pole on the bottom-most ghost, and then the third-from-the-bottom (or now second) ghost.
6. Your setup should look like the image below. The pole on the left at {-30.5, 24.5} is corrupted and is marked with the stone HERE.
7. If you try to save it will crash, with the bug report also attached.

Image

As some extra information. If the second pole you place is the 4th one and not the 3rd from the bottom, then the corrupted pole will be one tile up.

Hope this helps!
Attachments
map.zip
(1.73 MiB) Downloaded 132 times
FluidicPower_0.3.3.zip
(853.98 KiB) Downloaded 174 times
factorio-current.log
(33.03 KiB) Downloaded 195 times
Alt-F4 Author | Factorio Modder
My Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby
Official Contributor to Space Exploration
kovarex
Factorio Staff
Factorio Staff
Posts: 8207
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [Lou][1.1.27] Error ElectricPole.cpp:1371: Zero cnnection before non-zero in "..." at { }

Post by kovarex »

Thanks for the report, it is now fixed for the next release.
User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 419
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: [Lou][1.1.27] Error ElectricPole.cpp:1371: Zero cnnection before non-zero in "..." at { }

Post by Stringweasel »

Great news! Thanks for fixing the bug, even though it should likely never happen in vanilla or most mods! :D
Alt-F4 Author | Factorio Modder
My Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby
Official Contributor to Space Exploration
Post Reply

Return to “Resolved Problems and Bugs”