-
Notifications
You must be signed in to change notification settings - Fork 28
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
Hunting memory errors #52
Comments
Oh huh so the line that allocates the freed memory is this StringRef get_center_suffix() const noexcept override
{
const float state = morhp_state->get_value();
if( state <= 0.5 )
{
return String("L");
}
else
{
return String("R");
}
} but that returns a stack object into a ref which then will get destructed incorrectly. (Why that api is string_ref is actually odd). If I change that to |
Oh huh line 3443 has the same problem and is harder to fix. I'll put a hack into my PR but probably we will want a different approach |
The pattern StringRef foo() { return String( "bar" ); } can result in the string being freed before the ref is resolved. Address sanitizer shows this as a problem, as described in surge-synthesizer#52. I'm not sure if this fix is the right one or if we should instead change the API to String rather than StringRef, and especially the dynamic string one is iffy, but this at least squashes the memory problem the sanitizer showed in single instance.
The pattern StringRef foo() { return String( "bar" ); } can result in the string being freed before the ref is resolved. Address sanitizer shows this as a problem, as described in #52. I'm not sure if this fix is the right one or if we should instead change the API to String rather than StringRef, and especially the dynamic string one is iffy, but this at least squashes the memory problem the sanitizer showed in single instance.
So this evening before bed I turned on the address sanitizers in clang.
To do this add to
target_compile_options
after the warning disablement-fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer
and add athen i build and run the standalone and in a single instance if I just click back and forth on the shift and ctrl button at the top 10 times or so I get a crash and the following sanitizer output. Hard to trap this outside the sanitizer but putting it here in case it rings any bells.
The text was updated successfully, but these errors were encountered: