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

Fixed DantzigLCPSolver when getTotalDimension = 0 #634

Merged
merged 2 commits into from
Mar 20, 2016

Conversation

mkoval
Copy link
Collaborator

@mkoval mkoval commented Mar 17, 2016

The code previously checked for getNumConstraints() == 0, but not getTotalDimension() == 0. This caused the LCP solver to access invalid memory if constraints were present, but all constraints had getDimension() == 0. I ran into this using a ServoJointConstraint in a completely empty environment.

Thanks @jslee02 for helping me debug this.

This previously resulted in the LCP solver accessing invalid memory and
crashing.
size_t n = _group->getTotalDimension();

// If there is no constraint, then just return.
if (n == 0)
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: some compiler would complain to comparing signed and unsigned. if (0u == n) would help. also, @mxgrey would like to use Yoda conditions. 😉

@mxgrey
Copy link
Member

mxgrey commented Mar 17, 2016

Should it not be if (0u == n || 0u == numConstraints)?

@mkoval
Copy link
Collaborator Author

mkoval commented Mar 18, 2016

I don't see why we have to check numConstraints. Shouldn't getTotalDimension() return zero if the ConstraintGroup is empty?

@mxgrey
Copy link
Member

mxgrey commented Mar 18, 2016

You're right, zero dimensions also implies zero constraints. I assumed that the "dimension" referred to the dimension of the problem, not the sum of constraint dimensions. I should have checked the function definition.

👍

@jslee02 jslee02 added this to the DART 6.0.0 milestone Mar 18, 2016
jslee02 added a commit that referenced this pull request Mar 20, 2016
Fixed DantzigLCPSolver when getTotalDimension = 0
@jslee02 jslee02 merged commit 786d79c into dartsim:master Mar 20, 2016
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