Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/index.php/Reporting_Bug_Guidelines

Do NOT report bugs when a package is just outdated, or it is in Unsupported. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#56303 - [sdl2_mixer] version 2.0.2 is broken - Mix_Init always fails

Attached to Project: Arch Linux
Opened by Andrei Alexeyev (Akari) - Saturday, 11 November 2017, 23:47 GMT
Last edited by Sven-Hendrik Haase (Svenstaro) - Monday, 20 November 2017, 03:23 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Sven-Hendrik Haase (Svenstaro)
Architecture All
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:
SDL_mixer 2.0.2 always fails to initialize, thus every program that depends on it has no sound output.


Additional info:
* package version(s): 2.0.2
* upstream bug: https://bugzilla.libsdl.org/show_bug.cgi?id=3929
* Appears to have been fixed upstream: https://hg.libsdl.org/SDL_mixer/rev/7fa15b556953
* 2.0.1 is unaffected


Steps to reproduce:
cc mixtest.c `pkg-config SDL2_mixer --libs --cflags` -o mixtest && ./mixtest

This should print "Mix_Init() failed:" (with an empty error message), and exit with code 1. With a working SDL2_mixer, this program will produce no output and exit cleanly.

Attached: mixtest.c
This task depends upon

Closed by  Sven-Hendrik Haase (Svenstaro)
Monday, 20 November 2017, 03:23 GMT
Reason for closing:  Not a bug
Comment by Daniele (dan83h) - Sunday, 12 November 2017, 08:55 GMT Comment by Andrei Alexeyev (Akari) - Sunday, 12 November 2017, 09:36 GMT
@Daniele, yes I know how that function works. The problem is that in the broken version it ALWAYS fails, no matter which flags are passed to it. Did you try the test program?
Comment by Daniele (dan83h) - Monday, 13 November 2017, 07:20 GMT
yes, I tried:

$ cc mixtest.c -L/usr/local/lib/ -I /usr/local/include/SDL2 -lSDL2_mixer -lSDL2 -o mixtest
$ ./mixtest
Mix_Init() failed:

I changed your file mixtest.c
$ cc mixtest2.c -L/usr/local/lib/ -I /usr/local/include/SDL2 -lSDL2_mixer -lSDL2 -o mixtest2
$ ./mixtest2
Success SDL_AudioInit
Success Mix_Init

Attached: mixtest2.c

Comment by Andrei Alexeyev (Akari) - Monday, 13 November 2017, 10:41 GMT
The example given in the SDL_mixer documentation is plain WRONG! The & operator has lower precedence than ==, so that comparison is equivalent to (initted & (flags != flags)), obviously that always gives you 0.

Try compiling the attached (and also your) file like this:

clang -Wparentheses mixtest3.c `pkg-config --libs --cflags SDL2_mixer` -o mixtest && ./mixtest

I chose clang because it gives a more descriptive warning message. This is what I get:

$ clang -Wparentheses mixtest3.c `pkg-config --libs --cflags SDL2_mixer` -o mixtest && ./mixtest
mixtest3.c:18:50: warning: & has lower precedence than ==; == will be evaluated first [-Wparentheses]
printf("(want & have == want) == %i\n", want & have == want);
^~~~~~~~~~~~~~
mixtest3.c:18:50: note: place parentheses around the '==' expression to silence this warning
printf("(want & have == want) == %i\n", want & have == want);
^
( )
mixtest3.c:18:50: note: place parentheses around the & expression to evaluate it first
printf("(want & have == want) == %i\n", want & have == want);
^
( )
mixtest3.c:19:50: warning: & has lower precedence than !=; != will be evaluated first [-Wparentheses]
printf("(want & have != want) == %i\n", want & have != want);
^~~~~~~~~~~~~~
mixtest3.c:19:50: note: place parentheses around the '!=' expression to silence this warning
printf("(want & have != want) == %i\n", want & have != want);
^
( )
mixtest3.c:19:50: note: place parentheses around the & expression to evaluate it first
printf("(want & have != want) == %i\n", want & have != want);
^
( )
2 warnings generated.
want == 16
have == 0
((want & have) == want) == 0
((want & have) != want) == 1
(want & have == want) == 0
(want & have != want) == 0
Mix_Init() failed: OGG support not available



Comment by Sven-Hendrik Haase (Svenstaro) - Thursday, 16 November 2017, 12:43 GMT
Uh, so what do I do with this?
Comment by Eli Schwartz (eschwartz) - Thursday, 16 November 2017, 14:23 GMT
Well, it seems like a "requesting a backport to fix a regression" sort of bug report...
Comment by Doug Newgard (Scimmia) - Thursday, 16 November 2017, 14:33 GMT
I'm still not even sure there is a bug here. No response from upstream and no new release, seems like an important component not working completely would get more attention.
Comment by Andrei Alexeyev (Akari) - Friday, 17 November 2017, 21:22 GMT
If after having tried the provided test programs and at least one application that depends on SDL2_mixer you are still not sure that there is, in fact, a bug, then I'm afraid I can't do much to convince you. I'll make one futile attempt though. Here's a bug filed to a project that I'm actively involved in. Of course, it ended up being just another case of package maintainer braindeath.

https://github.com/taisei-project/taisei/issues/94
Comment by Alan (jazztickets) - Saturday, 18 November 2017, 19:32 GMT
It doesn't work because you're not calling Mix_OpenAudio before Mix_Init. From the docs: "This must be called before using other functions in this library."

https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_11.html#SEC11
Comment by Sven-Hendrik Haase (Svenstaro) - Saturday, 18 November 2017, 20:07 GMT
Alright, so is this user error or should I patch the package?
Comment by Alan (jazztickets) - Saturday, 18 November 2017, 21:02 GMT
User error.
Comment by Sven-Hendrik Haase (Svenstaro) - Saturday, 18 November 2017, 21:35 GMT
I'm going to wait for the user to come back to this and give them a chance to reply.
Comment by Andrei Alexeyev (Akari) - Monday, 20 November 2017, 00:47 GMT
Sorry about this, calling Mix_OpenAudio first indeed fixes the problem. Although the incorrect order also seems to work on every version except for 2.0.2 (current hg tip included).

Attached: test cases used to confirm this.

Documentation for SDL_Init is still misleading, however (and the example contains an error). I should probably report that upstream.

Loading...