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

Bug fix for segfault in fixStaticSegmentRules #27

Merged
merged 1 commit into from
Nov 22, 2017

Conversation

besmaller
Copy link
Contributor

fixStaticSegmentRules could cause a segfault when trying to access out of the range of the currentRuleChanges iterator, if the size of possibleRuleChanges was less than 3 (maxReplacementCount).

The case exhibiting the problem had music in the input wav file, which has characteristics different from speech, which resulted in an unexpectedly low number of possibleRuleChanges in a static segment.

@besmaller besmaller changed the title Bug fix for segfault issue #25 Bug fix for segfault in fixStaticSegmentRules Nov 22, 2017
Copy link
Owner

@DanielSWolf DanielSWolf left a comment

Choose a reason for hiding this comment

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

That's looking good! 😃 I added two minor comments. Could you make the according changes, then squash and force-push? Then I'll happily accept your PR!

@@ -134,14 +134,18 @@ RuleChanges getPossibleRuleChanges(const ContinuousTimeline<ShapeRule>& shapeRul

ContinuousTimeline<ShapeRule> fixStaticSegmentRules(const ContinuousTimeline<ShapeRule>& shapeRules, AnimationFunction animate) {
// The complexity of this function is exponential with the number of replacements. So let's cap that value.
const int maxReplacementCount = 3;
Copy link
Owner

Choose a reason for hiding this comment

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

maxReplacementCount can stay const!

for (int replacementCount = 1; bestScenario.getStaticSegmentCount() > 0 && replacementCount <= maxReplacementCount; ++replacementCount) {
for (
int replacementCount = 1;
bestScenario.getStaticSegmentCount() > 0 && replacementCount <= std::min((int)possibleRuleChanges.size(), maxReplacementCount);
Copy link
Owner

Choose a reason for hiding this comment

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

Could you change the C-style cast into a C++-style static_cast<int>()?

@besmaller
Copy link
Contributor Author

Still learning how to use git and proper github methodology, but I think I've implemented the changes you mentioned with the appropriate squash and force-push. I ran a local test on 32 and 64-bit builds as well (I need a 64-bit build to deal with a malloc issue in some of the wav files)

@DanielSWolf DanielSWolf merged commit 04595a0 into DanielSWolf:master Nov 22, 2017
@DanielSWolf
Copy link
Owner

Merged! (Travis CI automatically tests PRs in multiple environments, so I was pretty confident about this.)

BTW: Rhubarb always processes the input file in small chunks, so even a 32-bit build ought to be able to process arbitrarily long WAVE files. I once tested it with a 30-minute file without any problems and with rather low memory consumption. If you are having any trouble, it would be great if you could create an issue.

@besmaller
Copy link
Contributor Author

Thanks, Daniel. This issue resolution has been my first exposure to pull requests with github, and was quite educational. On the memory issue, I will recreate and open a new issue. I was tracking memory use by the app when it failed on a 10 minute podcast, and it looked like a the time of failure it needed about 1.4GB of memory.

@besmaller besmaller deleted the bugfix/#25-segfault branch November 30, 2017 04:59
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.

2 participants