Skip to content

Fix a few memory issues found with ASan#6843

Merged
sakertooth merged 6 commits into
LMMS:masterfrom
messmerd:asan-fixes
Sep 3, 2023
Merged

Fix a few memory issues found with ASan#6843
sakertooth merged 6 commits into
LMMS:masterfrom
messmerd:asan-fixes

Conversation

@messmerd
Copy link
Copy Markdown
Member

@messmerd messmerd commented Sep 3, 2023

I used an AddressSanitizer build to find and fix some memory issues:

  • Memory leak in LADSPA effects
  • Memory leak in SimpleTextFloat
  • Invalid iterator in AutomationClip
    • Occurred when adding and removing nodes in the Automation Editor
    • Likely the cause of Automation Editor crashes that I've experienced before
  • Buffer overflow in PianoView

I'm sure there are more memory-related errors I could find and fix with ASan, but this is enough for now.

Copy link
Copy Markdown
Member

@DomClark DomClark left a comment

Choose a reason for hiding this comment

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

Do you plan on contributing the CAPS changes upstream? I checked https://github.com/moddevices/caps-lv2 and it appears the destructor still isn't virtual there.

Comment thread src/core/AutomationClip.cpp
@messmerd
Copy link
Copy Markdown
Member Author

messmerd commented Sep 3, 2023

@DomClark
I just submitted a PR for the CAPS changes upstream: mod-audio/caps-lv2#32

I guess next I should revert those changes in this PR and then later update the CAPS submodule if/when it gets merged upstream?

@DomClark
Copy link
Copy Markdown
Member

DomClark commented Sep 3, 2023

I guess next I should revert those changes in this PR and then later update the CAPS submodule if/when it gets merged upstream?

I think it's fine to keep the changes here. It doesn't looks like we've updated CAPS in a long time, and doing so is probably a somewhat larger task that shouldn't be a prerequisite for this fix. We've made a number of changes to our vendored copy of CAPS anyway, so it's not as if there isn't precedent for fixing things here.

Comment thread src/core/AutomationClip.cpp
@sakertooth sakertooth merged commit 0768f5a into LMMS:master Sep 3, 2023
@messmerd messmerd deleted the asan-fixes branch September 3, 2023 21:42
@tresf
Copy link
Copy Markdown
Member

tresf commented Oct 20, 2023

I guess next I should revert those changes in this PR and then later update the CAPS submodule if/when it gets merged upstream?

I think it's fine to keep the changes here. It doesn't looks like we've updated CAPS in a long time, and doing so is probably a somewhat larger task that shouldn't be a prerequisite for this fix. We've made a number of changes to our vendored copy of CAPS anyway, so it's not as if there isn't precedent for fixing things here.

We have an open PR with the upstream fork here: #4027. I think it's worthwhile to send any patches there. Technically, they should probably go to Tim Goetze. I'm not sure how often moddevices sends their code to him. He's pretty picky about patches, quoting:

Contact
If you think you have found a bug in CAPS, or if you want to make a related or unrelated remark or inquiry please write to tim@quitte.de. 

Patches
Please do not send patches without asking first.  By submitting a patch, you claim sole authorship and agree that your submission becomes mine to use in any way I see fit, in exchange for no obligation on my part except attribution in the CAPS documentation. 

If we decide not to, that's OK too... the patches will just get lost once we upgrade and we'll have to backtrack a little.

@messmerd
Copy link
Copy Markdown
Member Author

@tresf I contacted Tim Goetze in early September and we agreed upon a solution to the memory leak, but he hasn't released a new version of CAPS yet. I don't know when/if he plans to.

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.

LMMS crashes when going left down piano in any instrument.

4 participants