cknave/kevedit

Testing Music in TOUR.ZZT crashes KevEdit

Opened this issue · 4 comments

in KevEdit 1.1.2, Testing the Title Board music contained in the music playing object (the 2 in the corner) can crash the program. I'm using the Windows version.

I was afraid of something like this when I updated the audio code. Could you let me know what version of Windows, what audio device, and what the default format is set to? (control panel > manage audio devices > [select your audio device] > properties > advanced)

Windows 10 21H1, Speakers (Conexant 20672 SmartAudio HD), default format is 16bit 48kHz.

Windows 10 21H2, using the Generic USB Audio driver, default format is 16bit 48khz.

To repro:
Have a series of #play statements with 241 32nd notes. no problem.
Add a 242nd 32nd note. Crash.

It will crash on fewer, but 242 is the limit. Testing 80 32nd notes will crash after the 11th attempt.

if you take a line of 8 32nd notes and paste it 19 times, and don't hit up, down, PgUp or PgDown after pasting and test it, it will crash.

if you take a line of 8 32nd notes and paste it 19 times, hit PgDn, and test, it will be fine, and then PgUp to the top and test, it will be fine. PgDown and test again, crash.

I can do all of these very consistently on my machine.

I can reproduce this with the pasting method on Windows 11. Stack trace:

(gdb) bt
#0  0x000000000041f76a in AudioCallback (userdata=0x7cf6d0, stream=0xb29a5c0 "", len=10584) at sdl_synth.c:228
#1  0x00007ffbf79e44d5 in ?? () from c:\Users\kvance\Desktop\SDL2.dll
#2  0x00007ffbf7a8c4c7 in SDL_DYNAPI_entry () from c:\Users\kvance\Desktop\SDL2.dll
#3  0x00007ffbf7b419ce in SDL_DYNAPI_entry () from c:\Users\kvance\Desktop\SDL2.dll
#4  0x00007ffc86d126bd in KERNEL32!BaseThreadInitThunk () from C:\WINDOWS\System32\kernel32.dll
#5  0x00007ffc87b6dfb8 in ntdll!RtlUserThreadStart () from C:\WINDOWS\SYSTEM32\ntdll.dll
#6  0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) list
223
224     void AudioCallback(void *userdata, Uint8 *stream, int len)
225     {
226             int i;
227             for(i = 0; i < len && playbufferloc < playbuffermax; i++) {
228                     stream[i] = masterplaybuffer[playbufferloc];
229                     playbufferloc++;
230             }
231             for(; i < len; i++)
232                     stream[i] = ((SDL_AudioSpec *)userdata)->silence;

The source address is invalid?

(gdb) p i
$11 = 0
(gdb) p playbufferloc
$12 = 0
(gdb) p playbuffermax
$10 = 4689888
(gdb) p masterplaybuffer
$9 = (Uint8 *) 0xb54f040 <error: Cannot access memory at address 0xb54f040>