Skip to content

Protos that Redefine Field Names Cause Unexpected Behavior #6630

Open
@CoolSpy3

Description

@CoolSpy3

Describe the Bug
It looks like this is a bug in the handling of proto fields with the same names. My best guess is that it's maybe a result of WbNode:1740 checking for field existence by name rather than something more robust.

I did some basic debugging and it looks like, for the example below, loading the proto causes Webots to recurse indefinitely on WbNode:1305 because node == this. In essence, this means that one of the nodes is considered its own subnode. My guess is that Webots thinks SolidProto.children = Group.children, so Group is contained in Group.children.

I've also noticed a few other cases where the code assumes that field names dictate their behavior (ex. WbField:336-343). (Although this example is not likely to cause this crash.)

Steps to Reproduce

  1. Create the following proto:
#VRML_SIM R2024a utf8

EXTERNPROTO "SolidProto.proto"

PROTO SolidProtoContainer [
  field MFNode children []
]
{
SolidProto {
  children [
    Group {
      children IS children
    }
  ]
}
}

(Note that this depends on the SolidProto.proto file in tests/api/protos)
2. Try to add the proto to a world
3. Webots crashes
4. Change the field name to children1 and try to load the proto again
5. Webots successfully loads the proto and does not crash.

Expected behavior
Webots should load the proto without crashing regardless of the field name.

System

  • Operating System: Windows 10
  • Graphics Card: NVIDIA GeForce GTX 1050 Ti

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcrashCause a crash

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions