-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Envelope triggered NaN #3408
Comments
@zonkmachine, I am not able to reproduce the problem. This might be the case because I don't have the zita reverb. However, you could try to trap the critical floating point exceptions to find out the location where the NaN is introduced. Here's some example code that I put together from various source on the net: #include <fenv.h> // For feenableexcept
#include <execinfo.h> // For backtrace and backtrace_symbols_fd
#include <unistd.h> // For STDERR_FILENO
#include <csignal> // To register the signal handler
#include <iostream>
void signalHandler( int signum ) {
std::cout << "Interrupt signal (" << signum << ") received.\n";
// Get a back trace
void *array[10];
size_t size;
// get void*'s for all entries on the stack
size = backtrace(array, 10);
backtrace_symbols_fd(array, size, STDERR_FILENO);
// cleanup and close up stuff here
// terminate program
exit(signum);
}
void triggerFloatingPointException()
{
float a = 1., b = 0.;
float c = a/b;
}
int main(void) {
// Enable exceptions for certain floating point results
feenableexcept(FE_INVALID |
FE_DIVBYZERO |
FE_OVERFLOW |
FE_UNDERFLOW);
// Install the trap handler
// register signal SIGINT and signal handler
signal(SIGFPE, signalHandler);
// Trigger an exception
triggerFloatingPointException();
return 0;
} I think it should be clear from the comments what happens where. If I understand correctly the settings for the exceptions are inherited by threads so you should enable them very early in LMMS' Also for the example above the backtrace only contained addresses on my machine but I guess it might suffice to simply set a breakpoint in the signal handler (haven't tried if this really works though). Good luck! :) |
Thanks for the debugging code!
Oh, zita. A mistake that one. I used it as the other ones changed when bisecting. I'll change that to one we ship. Calf reverb and ReverbSC works fine for this! ;) |
Fixed! |
@zonkmachine, thanks for the updated file! I am now also able to reproduce the problem. I have applied the code that I have posted above to the main function of LMMS and got some results. As a first step I needed to fix some other places in the code that triggered floating point exceptions in a rather hackish way. However, this was only done to get to the heart of the problem. The main problem is caused at the end of if( m_envLfoParameters[Volume]->isUsed() )
{
float volBuffer [frames];
m_envLfoParameters[Volume]->fillLevel( volBuffer, envTotalFrames, envReleaseBegin, frames );
for( fpp_t frame = 0; frame < frames; ++frame )
{
float vol_level = volBuffer[frame];
vol_level = vol_level * vol_level;
buffer[frame][0] = vol_level * buffer[frame][0];
buffer[frame][1] = vol_level * buffer[frame][1];
}
} After the volume buffer vol_level = vol_level * vol_level; Multiplying these two large negative numbers will likely result in a large positive number that exceeds the maximum for At first I thought it was a problem that |
Me to, it's brutal! :D |
@michaelgregorius If you have time and energy to take this on I suggest you assign this issue to yourself and then I should probably close #3381. I put #3381 on the RC3 roadmap https://github.com/LMMS/lmms/projects/2 but it looks like it's going to take far more work than just assign some new minimum values to the knobs. |
@zonkmachine, I think this is a potentially never ending story because I assume that all of the plugins contained with LMMS' might also cause floating point exceptions. So while everything might be nice with one project and set of plugins another project with another set might cause problems. What do you think about adding a CMake option that conditionally adds and compiles the code above so that LMMS developers just have to flip a switch if they want to hunt down potential problems? It could perhaps also be used to hunt down the elusive problem described in #1048. |
Yes, but I'm focused on the envelope/soundshaping part here.
Yes to this. I had a similar plan with 28b30d6 |
@zonkmachine hows this one coming? Is there anything I can do here to help out? |
I have added the pull request #3687 to provide an option to debug floating point exception. Please refer to the pull request for more details. |
The problem is: |
Should be fixed via #3761. |
Edit: Brief intro
To reproduce.
Load test project:envelopeNaN.mmp.zip
Play until loop. Sound disappears? If yes, proof. If no, reload project and try again.
Verbose intro
The sound went out, NaN style, when I tweaked the decay on an instrument while the song was playing. I set out to see if I could pinpoint the source and I eventually managed to find a way to reproduce it reliably enought to be able to bisect this and the bug seem to have been introduced in 9e1cdd0
The test project is a simple melody with a bitinvader synt having the volume envelopes release knob controlled by an automation track. There is a reverb on the end for detection purposes as having a reverb seem to enormously aggravate the issue. The NaN is however introduced before the effect chain.
If you play this track the sound may go silent somewhere during the first loop but if it makes it to the second you're safe and need to reopen the project and repeat 'play' until it eventually crashes. For me it will go silent at least one time out of four. Since the issue seem to clear itself up after the first run, I suspect an uninitialised variable somewhere but so far I haven't managed to fix this. We divide with zero in the envelope which I set out to 'fix' in issue #3381 but fixing that doesn't affect this issue at all. I have only seen this with the release button and I think only on the first loop.
If you introduce an
assert( ! isnanf( some buffer ) );
in the input of the FX chain you will see that the NaN is detected on either:This is related to #1048 and #3313 . I think this one should be fixed first as it's introduced first in the sound chain.
Test project: envelopeNaN.mmp.zip
The text was updated successfully, but these errors were encountered: