Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix behavior when provided a malformed parameters file #556

Merged
merged 5 commits into from
Jan 28, 2020

Conversation

jacobperron
Copy link
Member

Fixes #553.

  • Don't finalize parameters struct in rcl_parse_yaml_file function
    The function assumes that the structure has already been initialized, so it should be the callers
    responsibility to finalize it. Otherwise, this may lead to a double free as reported in SIGABRT parsing yaml config file (double free detected) #553.
  • Return an error code if there's a malformed parameters file
    This restores behavior that was lost when the '__params:=' syntax was deprecated in Promote special CLI rules to flags #495.
  • An extra guard was also added when finalizing the parameters struct.

The function assumes that the structure has already been initialized, so it should be the callers
responsibility to finalize it. Otherwise, this may lead to a double free as reported in #553.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
This restores behavior that was lost when the '__params:=' syntax was deprecated in #495.

An extra guard was also added when finalizing the parameters struct.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron
Copy link
Member Author

jacobperron commented Jan 17, 2020

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status (unrelated known issue)
  • Windows Build Status

Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got one suggestion for a comment improvement. The code looks good to me otherwise.

Can you add a test that tickles this problem?

Comment on lines 628 to 629
// If we return RCL_RET_ERROR then the argument contained the prefix '__params:=',
// but the parameter file may be malformed or does not exist.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest something like:

// If _rcl_parse_param_file_rule() returned RCL_RET_ERROR, then the argument contained the '__params:=' prefix,
// but parsing of the parameter file failed.  Get out early here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored: 0937963

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron
Copy link
Member Author

@clalancette I've added a test that fails without this fix. PTAL. 98433bc

Copy link
Contributor

@hidmic hidmic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, thanks for taking care @jacobperron !

rcl/test/rcl/test_arguments.cpp Show resolved Hide resolved
rcl/src/rcl/arguments.c Show resolved Hide resolved
Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with green CI.

Also warn about deprecated usage, even if there is an error parsing parameters file.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron
Copy link
Member Author

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Copy link
Contributor

@hidmic hidmic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! And test failures on MacOS seem unrelated.

@jacobperron jacobperron merged commit b6f6492 into eloquent Jan 28, 2020
@delete-merged-branch delete-merged-branch bot deleted the jacob/fix_553 branch January 28, 2020 19:33
@clalancette
Copy link
Contributor

@jacobperron I may be misunderstanding this, but I only see this commit on the Eloquent branch, not the master branch. If that is the case, we need to port it over to the master branch as well.

@jacobperron
Copy link
Member Author

This commit was only intended for the Eloquent branch. The bug was introduced when the old ROS CLI arguments were deprecated (see #553 (comment)). Since the deprecated syntax has since been removed on master, there is nothing to fix.

@clalancette
Copy link
Contributor

This commit was only intended for the Eloquent branch. The bug was introduced when the old ROS CLI arguments were deprecated (see #553 (comment)). Since the deprecated syntax has since been removed on master, there is nothing to fix.

Ah! I forgot about that, I was just noticing commits only on this branch. Thanks for the reminder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants