Integrated Dynamics

Integrated Dynamics

63M Downloads

Crash when displaying variable due to client-side PartStateException

Ryplinn opened this issue ยท 7 comments

commented

Issue type:

  • ๐Ÿ› Bug

Short description:

Inserting a variable card representing a somewhat abstracted expression, including map and apply operators at multiple levels of abstraction, into a display panel results in a client crash.

Summary of the offending expression:
apply(flip(map), map(flip(int_from_tag), list.append(list.append(apply(apply(list.append, []), "agri_growth"), "agri_gain"), "agri_strength")))

What I'm attempting to do is automatically grow 10/10/10 Agricraft seeds using fairly abstract code,
such that I can (e.g.) have a function better_than :: NBT -> NBT -> bool that takes the NBT from two seeds and decides whether to replace a growing crop, without duplicating a lot of intermediate variables.

Steps to reproduce the problem:

  1. Create a network with the following variable cards:

(building list agri_tag_names)

op List Append
list<string> []
string "agri_growth"
string "agri_gain"
string "agri_strength"
new_list: apply(list.append, [])
build_1: apply(new_list, "agri_growth")
build_2: list.append(build_1, "agri_gain")
agri_tag_names: list.append(build_2, "agri_strength")

Placing agri_tag_names into a display shows:
-agri_growth -agri_gain -agri_strength

int_from_tag: op NBT NBT Value Integer
flip(int_from_tag)
tag_getters: map(flip(int_from_tag), agri_tag_names)

A card with map(apply(flip(apply), seedNBT), tag_getters) correctly displays, e.g., -4 -5 -3, as expected.

op Map
flip(map)
apply(flip(map), tag_getters)

Placing the card with apply(flip(map), tag_getters) into the display triggers the crash.

Expected behaviour:

Not crashing


Versions:

  • This mod: IntegratedDynamics-1.12.2-1.1.6
  • Minecraft: 1.12.2
  • Forge: 14.23.5.2847
  • Modpack: MC Eternal 1.3.5.2 (tweaked to update Integrated Dynamics & Tunnels)

Log file:

crash-2020-05-18_16.13.10-client.txt

commented

Thanks for reporting!

commented

Simpler reproduction: apply(flip(map), map(+, [2,3,4]))

Variable cards:

sample_list: list [2, 3, 4]
+: op Arithmetic Addition
adders: map(+, sample_list)
op Operator Map
flip(map)
crash: apply(flip(map), adders)

Placing the crash card into a display will cause a client-side crash.

It's possible to detect an impending crash without actually triggering it: If you place the crashing card in the display without one of the intermediate variables in the network (such that the error message "Variable with id X could not be found within the current network" appears), then add the missing variable card, the display panel will disappear, and you can no longer interact with it via right-click. If you remove an intermediate variable again, the panel will re-appear.

It's still possible to break the invisible display panel in survival mode with a pickaxe, without triggering a crash. However, in my test world in creative mode, breaking the panel produced this server crash:

crash-2020-05-21_20.29.02-server.txt

I'm using the same 1.12.2 MC Eternal instance as my previous report.

commented

I made a test instance with only Integrated Dynamics, Cyclops Core, and Common Capabilities installed. apply(flip(map), map(+, [2,3,4])) again causes the crash.

crash-2020-05-21_20.56.48-client.txt

This mod: IntegratedDynamics-1.12.2-1.1.6
Minecraft: 1.12.2
Forge: 14.23.5.2854

commented

apply(get, map(+, [2,3,4])) also causes the crash (or at least makes the display panel disappear; didn't check for actual crash). However, I was still able to use the variable card in further calculations while it was in a disappeared panel!

variable cards:
sample_list, +, adders as above

get: op List Get
get_from_adders: apply(get, adders) // crashes
int 1
second_adder: apply(1, get_from_adders)
int 3
3+3: apply(3, second_adder)

Placing all the cards except get into the network shows this:
2020-05-29_02 02 45
(Cards in the panels, from left to right: sample_list, adders, get_from_adders, second_adder, 3+3)

Adding get to the network shows this:
2020-05-29_02 07 28

So there is a workaround to this problem -- don't display the crashing variable! They still seem to work in computations.

commented

I thought the problem might have something to do with applying a List -> ??? operator to a list of operators, since both get and flip(map) triggered the bug. However, I tried to trigger the bug with apply(flip(map), [op +, op -, op *] and it correctly displayed Applied Virtual Flipped [list;] :: Operator -> List with no issue.

Negative results are still results, I guess.

commented

I checked the minecraft log just prior to the 2020-05-18 client crash, and found this much more interesting exception:

[org.cyclops.integrateddynamics.core.helper.PartHelpers:writePartToNBT:105]:
  java.lang.ClassCastException:
  org.cyclops.integrateddynamics.core.evaluate.variable.ValueTypeListProxyOperatorMapped
  cannot be cast to
  org.cyclops.integrateddynamics.core.evaluate.variable.ValueTypeListProxyMaterialized

log-INFO-excerpt-Ryplinn-2020-05-18_16.12.43.txt

I see the same error in logs from my other testing.

commented

Oh, good catch @Ryplinn. That seems to be the root cause of the problem!