webots
webots copied to clipboard
Crash during PROTO regeneration triggered by nested PROTO in parameter
In the following world, change the Test2.t
translation value to make Webots crash.
World:
#VRML_SIM R2021b utf8
WorldInfo {
coordinateSystem "NUE"
}
Viewpoint {
orientation 0.3434989325345835 -0.9106458211432591 -0.22963595489801025 5.24359
position 3.6253302181468703 1.9376211271421955 2.5095511652221436
}
Background {
skyColor [
0.4 0.7 1
]
}
Test3 {
slot [
Test2 {
t 0.1 0 0
}
]
}
Test3.proto
#VRML_SIM R2021b utf8
PROTO Test3 [
field MFNode slot []
]
{
Solid {
children IS slot
}
}
Test2.proto
#VRML_SIM R2021b utf8
PROTO Test2 [
field SFVec3f t 0 0 0
]
{
Group {
children [
Test {
t IS t
}
]
}
}
Test.proto
#VRML_SIM R2021b utf8
PROTO Test [
field SFVec3f t 0 0 0
]
{
Transform {
translation %{=fields.t.value.x}% %{=fields.t.value.y}% %{=fields.t.value.z}%
children [
Shape {
geometry Box {
}
}
]
}
}
I tested with R2022a (Ubuntu 20.04) and I could not reproduce the crash. However, there is still a bug because the position of the box is not updated and Webots sometimes freeze several seconds when I change the t value.
My bad, it crashed in debug mode because this assert failed:
vrml/WbNode.cpp:123: void WbNode::setUniqueId(int): Assertion 'gRestoreUniqueIdOnClone || gNodes[newId] == NULL'
I did not managed to fix the problem but here is where I am so far:
- It crashes in
WbNode::setUniqueId
. We try to give the id of the old node to the newly generated one. However, the old one was not deleted (or at least not correctly) - The old node should have been deleted in
WbTemplateManager::regenerateNode
before the call tosetUniqueId
.- The node enters the condition
node->isProtoParameterNode()
. However, the parentField of the node is detected as a vector3 (it is thet
field)! So neither aWB_SF_NODE
nor aWB_MF_NODE
- Thus, we enter no condition and we just continue without deleting the node.
- The node enters the condition
I think the problem is here: we do not detect the right parent field