FS#59249 - [zsnes] Launches with segmentation fault

Attached to Project: Community Packages
Opened by James (Charadon) - Friday, 06 July 2018, 07:59 GMT
Last edited by Alexander F. Rødseth (xyproto) - Wednesday, 13 January 2021, 14:52 GMT
Task Type Bug Report
Category Packages: Multilib
Status Closed
Assigned To Alexander F. Rødseth (xyproto)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 7
Private No

Details

Description:
Zsnes fails to launch with a segmentation fault.

Additional info:
Here's a backtrace of the issue.
#0 0xf5f984e1 in pa_smoother_new ()
from /usr/lib32/pulseaudio/libpulsecommon-12.0.so
#1 0xf60029d4 in ?? () from /usr/lib32/libpulse.so.0
#2 0xf6219585 in pa_simple_new () from /usr/lib32/libpulse-simple.so.0
#3 0xf7ee31c5 in ?? () from /usr/lib32/libSDL-1.2.so.0
#4 0xf7eb5b63 in SDL_AudioInit () from /usr/lib32/libSDL-1.2.so.0
#5 0xf7eb47c1 in SDL_InitSubSystem () from /usr/lib32/libSDL-1.2.so.0
#6 0xf7eb58ef in SDL_OpenAudio () from /usr/lib32/libSDL-1.2.so.0
#7 0x5698595b in ?? ()
#8 0x5698907d in ?? ()
#9 0x56986334 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)



Steps to reproduce:
Launch the emulator
This task depends upon

Closed by  Alexander F. Rødseth (xyproto)
Wednesday, 13 January 2021, 14:52 GMT
Reason for closing:  Fixed
Comment by James (Charadon) - Tuesday, 31 July 2018, 23:44 GMT
I found a workaround by pointing the program to an older version of lib32-libpulse.
Comment by Eric Toombs (ewtoombs) - Sunday, 23 September 2018, 23:23 GMT
what version of lib32-libpulse did you switch to, Matthew?
Comment by Eric Toombs (ewtoombs) - Sunday, 23 September 2018, 23:24 GMT
I recompiled lib32-libpulse with -ggdb and got the following backtrace:

Thread 1 "zsnes" received signal SIGSEGV, Segmentation fault.
0xf5c12161 in pa_smoother_new (adjust_time=1000000, history_time=5000000,
monotonic=true, smoothing=true, min_history=4, time_offset=2289801946,
paused=true) at pulsecore/time-smoother.c:102
102 pa_assert(adjust_time > 0);
(gdb) bt
#0 0xf5c12161 in pa_smoother_new (adjust_time=1000000, history_time=5000000,
monotonic=true, smoothing=true, min_history=4, time_offset=2289801946,
paused=true) at pulsecore/time-smoother.c:102
#1 0xf5c7e164 in create_stream (direction=direction@entry=PA_STREAM_PLAYBACK,
s=0x570379f0, dev=0x0, attr=0x0, flags=<optimized out>, volume=0x0,
sync_stream=0x0) at pulse/stream.c:1257
#2 0xf5c7eaa0 in pa_stream_connect_playback (s=<optimized out>,
dev=<optimized out>, attr=<optimized out>, flags=<optimized out>,
volume=0x0, sync_stream=0x0) at pulse/stream.c:1402
#3 0xf5cb2865 in pa_simple_new (server=0x0, name=0xf7f3e675 "Test stream",
dir=PA_STREAM_PLAYBACK, dev=0x0,
stream_name=0xf7f3e639 "Simple DirectMedia Layer", ss=0xffffd4f8, map=0x0,
attr=0x0, rerror=0x0) at pulse/simple.c:206
#4 0xf7f175e3 in ?? () from /usr/lib32/libSDL-1.2.so.0
#5 0xf7ee9933 in SDL_AudioInit () from /usr/lib32/libSDL-1.2.so.0
#6 0xf7ee85f1 in SDL_InitSubSystem () from /usr/lib32/libSDL-1.2.so.0
#7 0xf7ee96bf in SDL_OpenAudio () from /usr/lib32/libSDL-1.2.so.0
#8 0x5698595b in ?? ()
#9 0x5698907d in ?? ()
#10 0x56986334 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Comment by Eric Toombs (ewtoombs) - Sunday, 23 September 2018, 23:42 GMT
I have confirmed that zsnes works with 11.1-1, but not with the version immediately following, 12.0-1. I'm making a test program to determine whether all SDL programs will fail, and whether 32-bit vs 64-bit is having any effect.
Comment by Eric Toombs (ewtoombs) - Monday, 24 September 2018, 18:18 GMT
I made a test program that calls SDL_OpenAudio(). It runs fine in 32bit and 64bit mode. I compiled it with the command gcc -m32 -ggdb -o main main.c -lSDL. I omitted the -m32 for the 64bit version.

It seems the trouble is coming from pa_assert(). It calls a real oddball piece of code called __x86.get_pc_thunk.bx() in libpulsecommon-12.2.so. While that code is running, the backtrace doesn't even work. So, there is something going on there that zsnes is allergic to.

I have attached the program and the gdb session.
   gdb.txt (1.8 KiB)
   main.c (0.4 KiB)
Comment by Eric Toombs (ewtoombs) - Monday, 24 September 2018, 20:06 GMT
I recompiled lib32-libpulse without optimisation (CFLAGS='-ggdb -fvar-tracking-assignments' and nothing else), and it works now! So, there's another workaround, which will allow the use of the newest version of libpulse.

Unfortunately, since this is a bug introduced by the optimisation, I have absolutely no idea how to fix it. I did learn, though, that it doesn't seem to have anything to do with __x86.get_pc_thunk.bx(). The segfault happens at address 0xf5c12161 in the attached assembly dump (movdqa xmm0,XMMWORD PTR [esp]). That instruction is after the thunk.
Comment by Eric Toombs (ewtoombs) - Monday, 24 September 2018, 22:23 GMT
In case it was relevant, I modified my test program so that it would actually emit sound. No difference. Here's the new test program.
   main.c (1.2 KiB)
Comment by ganthore (ganthore) - Sunday, 18 August 2019, 02:59 GMT
So we're getting very close to a whole year since the last comment about this bug report and the same error persists just as a gentle nudge. :-)
Comment by George Angelopoulos (gangelop) - Monday, 19 August 2019, 07:04 GMT
While this bug with lib32-libpulse still exists, zsnes now fails earlier with another segfault in lib32-libglvnd

#0 0x00000000f754eeeb __glDispatchCheckMultithreaded (libGLdispatch.so.0)
#1 0x00000000f770d9cf glXGetProcAddressARB (libGLX.so.0)
#2 0x00000000f7d6f6db n/a (libSDL-1.2.so.0)
#3 0x00000000f7d6fbfb n/a (libSDL-1.2.so.0)
#4 0x00000000f7d74e1a n/a (libSDL-1.2.so.0)
#5 0x00000000f7d753b2 n/a (libSDL-1.2.so.0)
#6 0x00000000f7d6350e SDL_SetVideoMode (libSDL-1.2.so.0)
#7 0x0000000056a794c7 n/a (zsnes)
#8 0x0000000056a7776b n/a (zsnes)
#9 0x0000000056a77d3d n/a (zsnes)
#10 0x0000000056a75334 n/a (zsnes)

The crash happens with lib32-libglvnd-1.1.0-1-x86_64.pkg.tar.xz
Last working version: lib32-libglvnd-1.0.0-1-x86_64.pkg.tar.xz (but still crashes on the lib32-libpulse bug).
Comment by Nelson (n3150n) - Monday, 23 March 2020, 02:24 GMT
Try adding your user to pulseaudio groups:

groupadd pulse
groupadd pulse-rt
groupadd pulse-access
gpasswd -a $USER pulse
gpasswd -a $USER pulse-rt
gpasswd -a $USER pulse-access

Had a similar issue which I solved by adding user to input group.

Note: still couldn't get around the latest bug using OpenGL, though.
Comment by Alexander F. Rødseth (xyproto) - Wednesday, 13 January 2021, 14:52 GMT
Thanks for reporting.

optdep on lib32-libpulse have been added.

Please re-open if this is still an issue.

See also: https://bugs.archlinux.org/task/53930

Loading...