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

Proper return value after assert #83

Merged
merged 10 commits into from
Jul 17, 2017

Conversation

mikaelarguedas
Copy link
Member

@mikaelarguedas mikaelarguedas commented Jul 10, 2017

In release mode these asserts are removed and the code keeps going through normal codepath, it should print errors and return values accordingly.

Replaces #80

Connects to #67

@mikaelarguedas
Copy link
Member Author

@pbeeson I reenabled the asserts here but printed proper error messages and return values as per your original fix. If you want to remove these asserts you'll need to use the binaries or compile your code with the build type "Debug".

@ros/ros_team This being a change in behavior for the released packages I'd like a review + feedback on the distributions it should be released into. Thanks!

@mikaelarguedas mikaelarguedas mentioned this pull request Jul 10, 2017
Copy link
Member

@dirk-thomas dirk-thomas left a comment

Choose a reason for hiding this comment

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

Since the changes "fix" undefined behavior I don't see a reason not to release it inot all ROS distros.

if (!gm_) {
ROS_ERROR_NAMED("actionlib", "Client should have valid GoalManager");
return CommState(CommState::DONE);
}
Copy link
Member

Choose a reason for hiding this comment

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

If gm_ is being checked that should happen at the beginning of the function. Otherwise line 94 would already 💥

@@ -154,12 +154,16 @@ class ManagedList
T& getElem()
{
assert(valid_);
if (!valid_)
ROS_ERROR_NAMED("actionlib", "getElem() should not see non-valid handles");
Copy link
Member

Choose a reason for hiding this comment

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

Please use { ... }. Otherwise the logic is broken if the macro is being defined as empty.

Arguably raising an exception might be more appropriate here.

Same below.

Nitpick: non-valid -> invalid.

{
ROS_ERROR_NAMED("actionlib", "execute_thread_ is null, skipping attempt to join it");
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

This is a case which shouldn't be possible based on the logic of the class. An assert which is also effective in release builds would be sufficient imo.

It could also be changed to:

if (execute_thread_) {
  execute_thread_->join();
  delete execute_thread_;
  execute_thread_ = NULL;
}

@mikaelarguedas
Copy link
Member Author

thanks for the feedback! Given that nothing throws in this code I didn't add exceptions for now. I think I address every other comment

@mikaelarguedas mikaelarguedas merged commit 8dae859 into indigo-devel Jul 17, 2017
@mikaelarguedas mikaelarguedas deleted the return_walue_after_assert branch July 17, 2017 23:58
@mikaelarguedas
Copy link
Member Author

thanks @pbeeson for reporting the issue and contributing a fix

@pbeeson
Copy link
Contributor

pbeeson commented Jul 18, 2017 via email

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