Skip to content

ParseString errors #948

Open
Open
@EGAlberts

Description

@EGAlberts

Describe the bug
There seem to be fundamental errors in the implementation of parseString inside tree_node.h. Particularly, the find operation is unsafe on L435 if getInput is called during construction. This is because the unordered_map is not instantiated yet. However this is only a side-issue of a more fundamental oversight.

It seems that it is not possible to properly declare your own enum and then parse strings into this, while ignoring the ScriptingEnums functionality. It seems this is a known issue to some extent as there is an exception made for NodeStatus on L433. The direct implication as it stands is that if someone were to use an InputPort for say NodeType, and safely getInput after construction, let's say in tick(), the parsing would be incorrect as it would turn the string provided into an int and then cast that int with NodeType.

How to Reproduce*

I made a fork of btcpp_sample to exemplify the core of the problem.
Here is the output of running the main.cpp there while using the current commit of this repo:

./build/btcpp_sample/btcpp_sample
Inside tick() with getInput:
IDLE
Undefined

Without getInput: 
IDLE
Control

As you can see due to the exemption in ParseString for NodeStatus it comes out correctly, but for NodeType it doesn't.

You can also find commented out code to exemplify the unsafe operation in the constructor.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions