Filter Helper


Adds context aware quick select for filter inserters.

Utilities
3 days ago
1.1 - 2.1
40.0K

g [Fixed] Server crash - get_filter() on non-storage logistic container

6 days ago

Calling entity.get_filter() on a logistic container that is not of
storage type throws and kills the whole multiplayer server.

Error:
Error while running event FilterHelper::on_gui_opened (ID 104)
Given logistic container isn't a storage type.
FilterHelper/filter_updaters.lua:219: in function 'get_active_items'
FilterHelper/control.lua:597: in function 'update_ui'
FilterHelper/control.lua:646

MultiplayerManager failed: "The mod Filter Helper (0.2.29)
caused a non-recoverable error."
Changing state from(InGame) to(Failed)

Reproduction:
1. Install FilterHelper 0.2.29 together with cargo-bay-inserters
(or any mod that adds a logistic container which is not storage type)
2. Host a multiplayer game
3. Open the GUI of that custom logistic container
4. Server crashes, everybody disconnects

Cause:
filter_updaters.lua calls entity.get_filter() unconditionally.
The one_filter_updater condition only excludes infinity-container:

return entity.filter_slot_count == 1
   and fh_util.get_effective_type(entity) ~= "infinity-container"

Custom logistic containers can have filter_slot_count == 1 while
still not supporting get_filter().

Affected lines: 219, 261, 268, 285

Suggested fix: wrap the calls, e.g.

local ok, filter = pcall(entity.get_filter, entity, 1)
if not ok then return {} end

or check entity.type first.

Tested on: Factorio 2.1.24 (build 87808).
With pcall guards applied the crash is gone.

4 days ago

It's interesting that there is a filter slot, but no filter available on it.

Thanks for the report. Will fix in the next version.

4 days ago

I can't seem to get this to crash. The mod you posted, cargo-bay-inserters (which is also deprecated), seems to work perfectly well with the inserters and FilterHelper.

Does this crash only in multiplayer? Does it work well in single player?

I don't doubt you got a crash, but I can't reproduce it with that mod. Can you send me a save?

4 days ago

Thanks for the quick reply.

One data point that might help:

I applied the pcall guards myself and the crash stopped completely.
Same dedicated server, same mod set, many hours of play since then -
no recurrence.

What I changed, in filter_updaters.lua:

line 219  one_filter_updater.get_active_items
line 261  many_filters_updaters.get_active_items
line 268  many_filters_updaters.add
line 285  many_filters_updaters.remove

Each one:

-- before
local filter = entity.get_filter(N)

-- after
local ok, filter = pcall(entity.get_filter, entity, N)
if not ok then filter = nil end

Regarding your questions:

  • Multiplayer, dedicated server. The failure was:
    MultiplayerManager failed: "The mod Filter Helper (0.2.29)
    caused a non-recoverable error."
    which dropped all players and stopped the server.

  • I have not tested single player.

  • You're right that cargo-bay-inserters probably isn't the source.

3 days ago

Can you try to isolate the issue? Save the game locally, then try to load it with various sets of mods, and see which one crashes.

3 days ago

Also, thanks for the pcall, I never knew that existed, and it can be a good solution anyway!

3 days ago

Hello!
I got this server crash with FilterHelper 0.2.29.

Error message:
Given logistic container isn't a storage type.
Stack trace: filter_updaters.lua update_filter_slot, triggered by on_gui_click when opening the GUI of a custom logistic container.

These containers are not standard storage containers and come from other mods, mainly the Py mod suite.
This is an unrecoverable hard crash, which instantly drops all players from the multiplayer server.

Full crash log snippet:

FilterHelper/filter_updaters.lua:19: in function 'update_filter_slot'
FilterHelper/filter_updaters.lua:225: in function <FilterHelper/filter_updaters.lua:224>
(...tail calls...)
FilterHelper/control.lua:684: in function <FilterHelper/control.lua:662>
25379.262 Error ServerMultiplayerManager.cpp:85: MultiplayerManager failed: "The mod Filter Helper (0.2.29) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event FilterHelper::on_gui_click (ID 1)
Given logistic container isn't a storage type.
stack traceback:
[C]: in function 'set_filter'
FilterHelper/filter_updaters.lua:19: in function 'update_filter_slot'
FilterHelper/filter_updaters.lua:225: in function <FilterHelper/filter_updaters.lua:224>
(...tail calls...)
FilterHelper/control.lua:684: in function <FilterHelper/control.lua:662>
25379.262 Info ServerMultiplayerManager.cpp:809: updateTick(22689115) changing state from(InGame) to(Failed)
25379.278 Info GlobalContext.cpp:763: Deleting active scenario.
25379.278 Quitting: multiplayer error.
25380.465 Info ServerMultiplayerManager.cpp:147: updateTick(18446744073709551615) changing state from(Failed) to(Closed)
25380.465 Info ServerMultiplayerManager.cpp:167: Deleting active scenario (global = true).
25380.468 Info HttpSharedState.cpp:57: Downloading https://multiplayer.factorio.com/remove-game/1817764
25380.742 Info UDPSocket.cpp:238: Closing socket
25380.742 Info UDPSocket.cpp:238: Socket closed
25381.769 Info UDPSocket.cpp:238: Closing socket
25381.769 Info UDPSocket.cpp:238: Socket closed
25381.787 Goodbye

plaintext

Would it be possible to add a check to skip unsupported container types, or wrap the filter update logic with pcall to avoid this fatal crash?
Thank you very much.

3 days ago

Your diagnosis was good, but the solution was not optimal.

Fixed now.

New response