zsnes crashes with segmentation fault on startup and the linux kernel reports general protection ip:f740f88d sp:fff20af8 error:0 in libc-2.18.so[f72e5000+1a1000] The issue appears to be due to glibc optimizing strstr() by calling __strstr_sse42() which requires the stack to be 16-byte aligned. Reproducible: Always Steps to Reproduce: 1. Emerge zsnes on a system with glibc-2.18 and has SSE 4.2 extensions 2. run zsnes Actual Results: zsnes crashes on startup. Expected Results: Zsnes starts up and runs normally. When zsnes first crashed on me it was in libGL.so not libc.so. However, I added the vaapi and vdapu USE flags to my system since then in hopes that it would fix the problem (as well as improve video performance). However, since the issue lies in the use of sse4.2 instructions and misaligned stacks, I suspect the same root cause as I am reporting now.
This is actually a duplicate of the archlinux bug (sorry, I didn't follow the URL in 488918 until just now). However, instead of patching glibc, I'll use the oppertunity to propose a patch for zsnes just in case my supposition in the additional notes section is correct.
Created attachment 371508 [details, diff] zsnes stack realignment patch This patch instructs gcc to realign the stack to a 16-byte boundary when startgame() is called. This patch allows zsnes to run correctly without the need to patch glibc.
Created attachment 371510 [details] emerge --verbose --info zsnes
For me (on Haswell/~amd64) it used to work without until yesterday or so but a world update broke it again. Segfault on startup - gone with your patch. Thanks...
ok, patch is in portage.
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c068f68557e6a0d7d2f5232221900205076429aa commit c068f68557e6a0d7d2f5232221900205076429aa Author: Sergei Trofimovich <slyfox@gentoo.org> AuthorDate: 2018-07-06 22:32:25 +0000 Commit: Sergei Trofimovich <slyfox@gentoo.org> CommitDate: 2018-07-06 22:33:09 +0000 games-emulation/zsnes: apply stack realignment to more functions Expand existing stack realignment hack to more C functions that get called from early init assembly. Fixes zsnes startup for me. Bug: https://bugs.gentoo.org/503138 Package-Manager: Portage-2.3.41, Repoman-2.3.9 .../zsnes/files/zsnes-1.51-stack-align-v2.patch | 56 ++++++++++ games-emulation/zsnes/zsnes-1.51-r7.ebuild | 122 +++++++++++++++++++++ 2 files changed, 178 insertions(+)