TTConvWavToMp4 Program Crashing
02:15 PM: Discovered a new bug in the TTConvWavToMp4 program in the Tommy’s Tunes software suite. When you run the program, and just after it finishes converting the first WAV file to MP4 format, you see one of those dialog boxes that informs you that the program had to end and asks if you want to send an error report to Microsoft. Investigating. See the comments below for details on the progress of this problem toward resolution.
November 27th, 2009 at 6:29 am
08:20 AM: I decided to work on this problem today because until it’s resolved, I can’t add too many songs to the music library; and there are lots of hits to add currently.
08:40 AM: Installing a debug version of the Tommy’s Tunes software, to see if the problem can be reproduced with this version.
08:42 AM: Debug version installed. Now attempting to reproduce the problem…
08:43 AM: This time, the program crashes immediately upon starting; it does not convert the first WAV file to MP4 before crashing. I’m going to apply any outstanding updates to this computer and try it again, before I delve into my software to find the problem.
08:51 AM: All updates have been applied. But the program still crashes immediately upon startup. So the next step is to find the exact spot in the code where the crash is occurring. I’m doing this now.
09:13 AM: The crash is happening in the DoTimer7Processing() function, due to an invalid parameter being passed to the strcpy() funcion. Investigating…
09:16 AM: I have the exact line in the above routine where the crash is happening. So I’m setting a break point there and running the program again so I can inspect the parameters to strcpy() before it gets called.
09:58 AM: I found a fix for the crash. The original line that was triggering the crash was as follows:
Investigation revealed that the second parameter, the size of the destination buffer pointed to by the first parameter, is 3. But it should be exactly 4, because the strcpy_s() function not only copies the contents of the source string itself, but also appends a NULL character to the destination string. So, the size we assign in the second parameter must include an extra byte for this NULL character. The original code did account for this extra character.
So I changed the line to the following:
and this stopped the crashing and restored normal operation of this program.
10:12 AM: It’s not clear why this only just now started failing because to my knowledge, I’ve not changed this code for several years. So I’m going to look at some of my backups and see if when I upgraded to Visual Studio 2008, if the automated migration process changed this code. Investigating…
10:22 AM: I looked at a backup from 2008-10-25, and the original line above has been as it is since then, at least. So something must have changed in some runtime library somewhere. Oh well, live, learn, and wonder too. I’ll make this change in the other conversion programs as well. Stand by…
10:34 AM: The above change has been applied to all conversion programs in the Tommy’s Tunes software suite. A complete system build is underway.
10:39 AM: Both debug and release versions of the software have finished successfully. Now, I’m installing and testing the programs…
11:15 AM: This program just successfully converted 26 wav files to MP4, and at least ten of the resulting files play fine, as verified by me. I’d say therefore, that this problem is solved.
May 5th, 2010 at 7:47 am
[...] Business 2009-11-11 on Mom’s Status: 2009-11-11Toms Diary – Todays Business 2009-11-11 on TTConvWavToMp4 Program CrashingToms Diary – Todays Business 2009-11-11 on Diary Revisions: 2009-11-11Toms Diary – Todays Business [...]