FFmpeg download Catch-22

This only happens with the experimental VS 2012 Project. I grabbed SVN HEAD (R13340) yesterday; it looks like it should be the release version of 2.0.6. Because I was previously running 2.0.5 I had the old FFmpeg installed. The compile went fine in both Debug & Release. The first time I launched Audacity 2.0.6 I did so via the debugger using the Debug build. It got past asking me if I wanted to reset preferences but then asserted/crashed. The problem is in this section of code at or near line number 849 of file srcFFmpeg.cpp:

   // Show the actual libraries loaded
   if (avutil) {
      //efm5 debug
      //wxLogMessage(wxT("Actual avutil path %s"),
      //           FileNames::PathFromAddr(avutil->GetSymbol(wxT("avutil_version"))).c_str());
   }
   if (avcodec) {
      //efm5 debug
      //wxLogMessage(wxT("Actual avcodec path %s"),
      //           FileNames::PathFromAddr(avcodec->GetSymbol(wxT("avcodec_version"))).c_str());
   }
   if (avformat) {
      //efm5 debug
      //wxLogMessage(wxT("Actual avformat path %s"),
      //           FileNames::PathFromAddr(avformat->GetSymbol(wxT("avformat_version"))).c_str());
   }

The actual problem is somewhere in:

FileNames::PathFromAddr(avutil->GetSymbol(wxT("avutil_version"))).c_str()

and her brethren. As you can see above I have commented these out and got Audacity run successfully, open Preferences, open the Libraries panel and ultimately download the new version of FFmpeg library.

    // Returns a pointer to the symbol on success, or NULL if an error occurred
    // or the symbol wasn't found.
    void *GetSymbol(const wxString& name, bool *success = NULL) const;

Note that while error-checking is available we are not attempting to use. Getting ridiculously exhaustive:

      //wxLogMessage(wxT("Actual avutil path %s"),
      //           FileNames::PathFromAddr(avutil->GetSymbol(wxT("avutil_version"))).c_str());
      bool theError = false;
      wxString theVersion(wxT("avutil_version"));
      void * thePointer = avutil->GetSymbol(theVersion.c_str(), &theError);
      wxString thePath = FileNames::PathFromAddr(thePointer);

I broke the Log Message parameter out into each of its individual component parts. Single stepping through this new code I can show that the error occurs at the line:
void * thePointer = avutil->GetSymbol(theVersion.c_str(), &theError);
crash.png
As you can see in the picture the complaint is “Can’t load symbol from unloaded library”.

Are you sure this is only with VS2012, Ed? I have seen this on VS 2008 and Martyn Shaw has seen it (I don’t know if he is still on VS 2008).

A developer would add FFmpeg using audacity.cfg if he/she could not bypass the assert.

A user of release builds gets told that FFmpeg was configured successfully before but they should now reconfigure it.


Gale

100% repeatable on VS2012 (which I built at least 200 times in the last 2 days trying to get VS2012 2.0.6 to compile & run-so far unsuccessfully). I do see the “FFmpeg was configured successfully before but they should now reconfigure it” with (almost?) each new VS2008 2.0.6 compile (but I have not tried since using the new FFmpeg installer & reinstalling - to a different drive, renamed the old folders - Lame). I know the VS2012 Project is unsupported. I just wish someone who knew the compilers would figure out why the Debug configuration runs fine but the Release does not.

After hours of tracking down the problem . Since I still have not gotten it to run in Release, I am not sure if FFmpeg is even working (though running the Debug via double-clicking the icon and Importing an FFmpeg-needed file works great). Just uncommented one of the Log calls and built Debug with the new FFmpeg installed - the problem is still there even with the new FFmpeg installed.

So there are two issues using VS2012 in 2.0.7-alpha, as I understand it.

1 The release build crashes before the app window appears: https://forum.audacityteam.org/t/experimental-vs-2012-project-broken/35677/1 .

2 The debug build asserts with an FFmpeg-related error “Can’t load symbol from unloaded library” even if FFmpeg 2.2.2 is correctly installed to %PROGRAM FILES%FFmpeg for Audacity.

So I would suggest these should be tracked on bugzilla as soon as you we have sufficient information.

Do #1 and #2 occur even if you just execute audacity.exe, or do they only occur if you run Audacity from within VS2012?


Gale

First, I have not tested 2.0.7-alpha just 2.0.6 Release although I expect the issues to present In the alpha.

Issue 1: there is something wrong with the hash tables. In the post to which you link I found that the hash pool dirTopPool caused a problem after approximately 164 entries. I spent another day today trying to figure out why the hash tables in the Command Manager are suffering exactly the same problem – after approximately 164 entries a problem appears. If you run either the Release or the Debug build from within the VS 2012 debugger there is no problem – everything works properly. However, if you run either the Release or the Debug build by double-clicking on their icons the problem is 100% repeatable. This is incredibly difficult to debug! The only debugging method is to insert MessageBox statements surrounding each potentially offensive statement and see where the problem occurs. This is an “hard crash” – the Windows dialog “Windows is checking for a solution…” appears.

Issue 2: this one raises its ugly head whether run from within the VS 2012 debugger or just by double-clicking the icon. From within the debugger you get an Assert and a forced Break; via double-click it is an “hard crash” unless the dialog “the libraries were found before… reconfigure” appears.

I see no point in raising Issue 1 on Bugzilla. I see strong support on the Developer List for moving to VS 2013; If these problems persist with VS 2013 the Developer responsible for the Project conversion will immediately hit these stumbling blocks. I was just hoping that someone else was also trying to get VS 2012 going and would chime in here.

I think you already have something appropriate on Bugzilla for issue 2.

Where is that, Ed?


Gale

That’s why they don’t pay me for thinking ! I’m pretty sure I’ve seen the topic discussed at length – most likely on the Developer List…here it is bugzilla:
http://bugzilla.audacityteam.org/show_bug.cgi?id=342
The title is now misleading but, starting with the second comment, you can see that Leland Lucius is probably the go-to person for this.

Yes I know that bug (as stated). But I understood the problem was

2 The debug build asserts with an FFmpeg-related error “Can’t load symbol from unloaded library” even if FFmpeg 2.2.2 is correctly installed to %PROGRAM FILES%FFmpeg for Audacity.

I understood that because you said that

running the Debug via double-clicking the icon and Importing an FFmpeg-needed file works great

If that was tagged 2.0.6 then FFmpeg 2.2.2 must be correctly installed, and so if Debug crashes from within VS then it is doing so despite correct FFmpeg installation. So bug 342 doesn’t seem relevant at first sight.

But to test your theory you could apply Leland’s patch and see if the issue goes away, no?


Gale

Sorry, I’m chasing down so many VS 2012 related problems I can’t keep all the symptoms in mind. The “debug build runs fine or running either build under the debugger works fine” was probably only related to the HashTable bug. I think that bug 342 is sufficiently related, especially since it drifted almost immediately off-topic. I have not looked at the patch but from what I read on the Developer List and what I see in the source code it looks like a lot of the Dynamic Library loading code is in place and the wrapping #defines have not been used to turn it off. Just now I took a quick look at the code again and I might know what’s going on – I’ll do some more digging.

Nope, sorry – just spaghetti code which needed some thought to figure out.

I think this may be pertinent to bug 342; take a look at this image:


Note that even though Audacity’s preferences has it correctly “spelled”, on this rare occasion (in this case it is 2.0.5 Release) where Audacity can’t seem to find the FFmpeg library the dialog as a mangled filename string. Going through the Browse button and choosing the appropriate DLL did not resolve the issue. I had to manually type complete, correctly qualified path and filename with extension to get it to recognize the library. I have no idea why this occurred but if I am ever in the debugger when it happens I will try to figure out what happened.

I only noticed this because I have a new, larger monitor on which i can (just barely) read the tiny font of this dialog.

I think that is something peculiar to your development environment, Ed, or a very rare moonphase bug I’ve never heard of where the “Locate” dialogue doesn’t read audacity.cfg properly. If I mangle the path to FFmpeg in .cfg, the “Locate” dialogue accurately repeats the mangled path.

Typing in the “Locate” dialogue should have no effect whatsoever in the current code. So that path should be made uneditable, IMHO.


Gale

“peculiar” – the perfect word !