We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5511 - Infinite loop playing short/invalid midi with timidity
Summary: Infinite loop playing short/invalid midi with timidity
Status: NEW
Alias: None
Product: SDL_mixer
Classification: Unclassified
Component: misc (show other bugs)
Version: 2.0.4
Hardware: All Linux
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-28 21:40 UTC by Ralph Versteegen
Modified: 2021-01-29 11:24 UTC (History)
1 user (show)

See Also:


Attachments
A zero-length MIDI file (41 bytes, audio/midi)
2021-01-28 21:40 UTC, Ralph Versteegen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ralph Versteegen 2021-01-28 21:40:53 UTC
Created attachment 4730 [details]
A zero-length MIDI file

When playing the attached MIDI file using SDL_mixer's Timidity backend the "SDLAudioP2" thread gets stuck in an infinite loop in music_pcm_getaudio and the program will freeze when calling Mix_LockAudio

Happens on both x86 and x86_64 Linux (presumably OS-independent). Present in latest SDL_mixer hg rev, 2.0.3 and 2.0.4.

(gdb) bt
#0  0xf7f3b8e8 in __lll_lock_wait () from /lib/libpthread.so.0
#1  0xf7f32459 in pthread_mutex_lock () from /lib/libpthread.so.0
#2  0xf7e5dccf in ?? () from /usr/lib/libSDL2-2.0.so.0
#3  0xf7d85636 in ?? () from /usr/lib/libSDL2-2.0.so.0
#4  0xf7d52812 in Mix_LockAudio () from /usr/lib/libSDL2_mixer-2.0.so.0
#5  0xf7d539c5 in Mix_FreeMusic () from /usr/lib/libSDL2_mixer-2.0.so.0

(gdb) bt
#0  0xf7d5adf3 in Timidity_Start () from /usr/lib/libSDL2_mixer-2.0.so.0
#1  0xf7d57ad0 in TIMIDITY_GetSome () from /usr/lib/libSDL2_mixer-2.0.so.0
#2  0xf7d52d9a in music_pcm_getaudio () from /usr/lib/libSDL2_mixer-2.0.so.0
#3  0xf7d5799c in TIMIDITY_GetAudio () from /usr/lib/libSDL2_mixer-2.0.so.0
#4  0xf7d52ee8 in music_mixer () from /usr/lib/libSDL2_mixer-2.0.so.0
#5  0xf7d50ffa in mix_channels () from /usr/lib/libSDL2_mixer-2.0.so.0
#6  0xf7d844f6 in ?? () from /usr/lib/libSDL2-2.0.so.0
#7  0xf7de861b in ?? () from /usr/lib/libSDL2-2.0.so.0
#8  0xf7e5d54b in ?? () from /usr/lib/libSDL2-2.0.so.0
#9  0xf7f2f517 in start_thread () from /lib/libpthread.so.0
#10 0xf77bd146 in clone () from /lib/libc.so.6

There's likely something wrong with the file. Timidity plays a single note, ADLMIDI plays nothing.
Comment 1 Ralph Versteegen 2021-01-28 21:42:42 UTC
I forgot to say: I stepped through music_pcm_getaudio with gdb and saw that in the following loop len = 8192, volume = MIX_MAX_VOLUME but consumed = 0.


    while (len > 0 && !done) {
        int consumed = GetSome(context, dst, len, &done);
        if (consumed < 0) {
            break;
        }

        if (volume == MIX_MAX_VOLUME) {
            dst += consumed;
        } else {
            SDL_MixAudioFormat(snd, dst, music_spec.format, (Uint32)consumed, volume);
            snd += consumed;
        }
        len -= consumed;
    }
Comment 2 Ralph Versteegen 2021-01-28 21:44:34 UTC
Also forgot: repro steps: play with "playmus -l GURGU.mid", then try to quit with Ctrl-C. It won't.