PLCgen crashes on nested tuple types
The following CIF model crashes PLCgen:
automaton a:
disc tuple(tuple(int a, b) c, d) v;
location:
initial;
end
With:
java.util.ConcurrentModificationException
at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1221)
at org.eclipse.escet.cif.plcgen.generators.DefaultTypeGenerator.convertTupleType(DefaultTypeGenerator.java:112)
at org.eclipse.escet.cif.plcgen.generators.DefaultTypeGenerator.convertType(DefaultTypeGenerator.java:95)
at org.eclipse.escet.cif.plcgen.generators.DefaultVariableStorage.addStateVariable(DefaultVariableStorage.java:70)
at org.eclipse.escet.cif.plcgen.generators.CifProcessor.process(CifProcessor.java:143)
at org.eclipse.escet.cif.plcgen.targets.PlcBaseTarget.generate(PlcBaseTarget.java:193)
at org.eclipse.escet.cif.plcgen.CifPlcGenApp.runInternal(CifPlcGenApp.java:125)
at org.eclipse.escet.common.app.framework.Application.runApplication(Application.java:315)
at org.eclipse.escet.common.app.framework.ChildAppStarter$1.run(ChildAppStarter.java:286)
at java.base/java.lang.Thread.run(Thread.java:840)
The problem is that DefaultTypeGenerator.convertType
for the outer tuple type invokes convertTupleType
, which does structTypes.computeIfAbsent(typeWrap, key -> makePlcStructType(tupleType))
, and in makePlcStructType
again convertType
is invoked for the inner tuple type, which again invokes convertTupleType
, which also executes structTypes.computeIfAbsent(typeWrap, key -> makePlcStructType(tupleType))
, meaning structTypes
is modified for the inner one while the outer one is also working on/with it.
I found this while making test models for #798 (closed).