moreblocks:circular_saw Server crash #7785

Open
opened 2024-12-02 16:16:20 +01:00 by sixer · 5 comments

As the server crashed right after me clicking when trying to recycle cut blocks into base blocks on saw, I think I may have accidentally caused it.

The reproduction for the bug, if you want to test and fix on testserver:

  • put about 80 healing tree wood into saw
  • put two 2/16 healing tree slabs to "recycle output" - nothing happens, the slabs are there
  • Take four 4/16 healing tree slabs out of inventory and click on the "recycle output" slot with those 2/16 slabs -> once I have did that, I saw the crash window immediately
As the server crashed right after me clicking when trying to recycle cut blocks into base blocks on saw, I think I may have accidentally caused it. The reproduction for the bug, if you want to test and fix on testserver: * put about 80 healing tree wood into saw * put two 2/16 healing tree slabs to "recycle output" - nothing happens, the slabs are there * Take four 4/16 healing tree slabs out of inventory and click on the "recycle output" slot with those 2/16 slabs -> once I have did that, I saw the crash window immediately
Member
2024-12-02 15:07:26: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'moreblocks' in callback nodemeta_inventory_OnPut(): ....0/Yourland_main/bin/../mods/moreblocks/circular_saw.lua:312: attempt to perform arithmetic on local 'cost' (a nil value)
2024-12-02 15:07:26: ERROR[Main]: stack traceback:
2024-12-02 15:07:26: ERROR[Main]: ....0/Yourland_main/bin/../mods/moreblocks/circular_saw.lua:312: in function <....0/Yourland_main/bin/../mods/moreblocks/circular_saw.lua:293>
```fortran 2024-12-02 15:07:26: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'moreblocks' in callback nodemeta_inventory_OnPut(): ....0/Yourland_main/bin/../mods/moreblocks/circular_saw.lua:312: attempt to perform arithmetic on local 'cost' (a nil value) 2024-12-02 15:07:26: ERROR[Main]: stack traceback: 2024-12-02 15:07:26: ERROR[Main]: ....0/Yourland_main/bin/../mods/moreblocks/circular_saw.lua:312: in function <....0/Yourland_main/bin/../mods/moreblocks/circular_saw.lua:293> ```
whosit changed title from Server crash to moreblocks:circular_saw Server crash 2024-12-02 16:51:58 +01:00
whosit added the
1. kind/bug
2. prio/critical
labels 2024-12-02 16:52:12 +01:00
Member

Easier way to reproduce:

  1. fill the input slot with a stack of material
  2. put first type of microblock into recycle slot (so it stays in there and does not go into leftovers)
  3. try to put second type of microblock into recycle slot on top of the first one - get crash.

There's some weird way to make recycle slot keep material even when input is not full, but it's a separate bug X)

Easier way to reproduce: 1. fill the input slot with a stack of material 2. put first type of microblock into recycle slot (so it stays in there and does not go into leftovers) 3. try to put _second_ type of microblock into recycle slot on top of the first one - get crash. There's some weird way to make recycle slot keep material even when input is not full, but it's a separate bug X)
whosit added the
3. source/mod upstream
label 2024-12-04 21:53:19 +01:00
Member

What's interesting, if I try doing this on 5.10 + More Blocks from CDB - I get this crash.
If I try repro on 5.7 (and probably 5.8) + More Blocks from CDB - I get saw inventory wipe, same as #1792

So looks like another engine change (I added print to on_metadata_inventory_put and IIRC it gets called as if I put a whole block into recycle - and I do not do that, it's part of the reason for crash).

What's interesting, if I try doing this on 5.10 + More Blocks from CDB - I get this crash. If I try repro on 5.7 (and probably 5.8) + More Blocks from CDB - I get saw inventory wipe, same as #1792 So looks like another engine change (I added print to `on_metadata_inventory_put` and IIRC it gets called as if I put a whole block into recycle - and I do not do that, it's part of the reason for crash).
Member

My "hotfix" (it's in temp_fix_moreblocks_circular_saw_crash)

diff --git a/circular_saw.lua b/circular_saw.lua
index 02f58bd..7aad033 100644
--- a/circular_saw.lua
+++ b/circular_saw.lua
@@ -251,6 +251,10 @@ function circular_saw.allow_metadata_inventory_put(
                if not inv:contains_item("output", stackname) then
                        return 0
                end
+                -- prevent inventory wipe?
+               if not (inv:contains_item("recycle", stackname) or inv:is_empty("recycle")) then
+                       return 0
+               end
                local stackmax = stack:get_stack_max()
                local instack = inv:get_stack("input", 1)
                local microstack = inv:get_stack("micro", 1)
@@ -307,6 +311,7 @@ function circular_saw.on_metadata_inventory_put(
        elseif listname == "recycle" then
                -- Lets look which shape this represents:
                local cost = circular_saw:get_cost(inv, stackname)
+               --if not cost then return 0 end -- try to prevent crash (but still wipes inv) -- this is not deployed
                local input_stack = inv:get_stack("input", 1)
                -- check if this would not exceed input itemstack max_stacks
                if input_stack:get_count() + ((cost * count) / 8) <= input_stack:get_stack_max() then

I have no idea what I did, but it stopped crashing :p

My "hotfix" (it's in `temp_fix_moreblocks_circular_saw_crash`) ```diff diff --git a/circular_saw.lua b/circular_saw.lua index 02f58bd..7aad033 100644 --- a/circular_saw.lua +++ b/circular_saw.lua @@ -251,6 +251,10 @@ function circular_saw.allow_metadata_inventory_put( if not inv:contains_item("output", stackname) then return 0 end + -- prevent inventory wipe? + if not (inv:contains_item("recycle", stackname) or inv:is_empty("recycle")) then + return 0 + end local stackmax = stack:get_stack_max() local instack = inv:get_stack("input", 1) local microstack = inv:get_stack("micro", 1) @@ -307,6 +311,7 @@ function circular_saw.on_metadata_inventory_put( elseif listname == "recycle" then -- Lets look which shape this represents: local cost = circular_saw:get_cost(inv, stackname) + --if not cost then return 0 end -- try to prevent crash (but still wipes inv) -- this is not deployed local input_stack = inv:get_stack("input", 1) -- check if this would not exceed input itemstack max_stacks if input_stack:get_count() + ((cost * count) / 8) <= input_stack:get_stack_max() then ``` I have no idea what I did, but it stopped crashing :p
AliasAlreadyTaken added this to the Alias@work project 2024-12-17 20:04:39 +01:00
Member
Upstream issue: https://github.com/minetest-mods/moreblocks/issues/213
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: your-land/bugtracker#7785
No description provided.