Example using mednafen core (it also crashes with all others cores) : $ jollygood -v -w -c mednafen "Final Fantasy VI.sfc" *** buffer overflow detected ***: terminated If built with : -D_FORTIFY_SOURCE=2 -U_GLIBCXX_ASSERTIONS then it starts fine, no buffer overflow. Reproducible: Always Portage 3.0.44 (python 3.10.9-final-0, default/linux/amd64/17.1/no-multilib/hardened, gcc-12, glibc-2.36-r5, 6.1.12-gentoo-hardened x86_64) ================================================================= System uname: Linux-6.1.12-gentoo-hardened-x86_64-AMD_A10-6800K_APU_with_Radeon-tm-_HD_Graphics-with-glibc2.36 KiB Mem: 32353084 total, 287444 free KiB Swap: 16777212 total, 16776176 free Timestamp of repository gentoo: Fri, 24 Feb 2023 13:30:01 +0000 Head commit of repository gentoo: 2953e1093acd734f2cc5554d34698643322f129f Timestamp of repository localrepo: Wed, 22 Feb 2023 14:51:47 +0000 Timestamp of repository mv: Thu, 23 Feb 2023 13:47:14 +0000 Head commit of repository mv: 6ac4b786c4a881c7645d4e2ece1d3b047081b367 Timestamp of repository vapoursynth: Thu, 23 Feb 2023 13:47:17 +0000 Head commit of repository vapoursynth: 683ed756afd98d75994b5b3add6defb63a1e4cc2 sh bash 5.1_p16-r2 ld GNU ld (Gentoo 2.39 p5) 2.39.0 app-misc/pax-utils: 1.3.5::gentoo app-shells/bash: 5.1_p16-r2::gentoo dev-java/java-config: 2.3.1::gentoo dev-lang/perl: 5.36.0-r1::gentoo dev-lang/python: 2.7.18_p16-r1::gentoo, 3.10.9-r1::gentoo, 3.11.1-r1::gentoo dev-lang/rust: 1.66.1::gentoo dev-util/cmake: 3.25.2::gentoo dev-util/meson: 1.0.0::gentoo sys-apps/baselayout: 2.9::gentoo sys-apps/openrc: 0.45.2-r2::gentoo sys-apps/sandbox: 2.29::gentoo sys-devel/autoconf: 2.13-r7::gentoo, 2.71-r5::gentoo sys-devel/automake: 1.16.5::gentoo sys-devel/binutils: 2.39-r4::gentoo sys-devel/binutils-config: 5.4.1::gentoo sys-devel/clang: 15.0.7-r1::gentoo sys-devel/gcc: 12.2.1_p20230121-r1::gentoo sys-devel/gcc-config: 2.8::gentoo sys-devel/libtool: 2.4.7-r1::gentoo sys-devel/llvm: 15.0.7::gentoo sys-devel/make: 4.3::gentoo sys-kernel/linux-headers: 5.15-r3::gentoo (virtual/os-headers) sys-libs/glibc: 2.36-r5::gentoo Repositories: gentoo location: /var/db/repos/gentoo sync-type: rsync sync-uri: rsync://rsync.gentoo.org/gentoo-portage priority: -1000 volatile: True sync-rsync-verify-max-age: 24 sync-rsync-verify-jobs: 1 sync-rsync-extra-opts: sync-rsync-verify-metamanifest: yes localrepo location: /var/db/repos/localrepo masters: gentoo volatile: True mv location: /var/db/repos/mv sync-type: git sync-uri: https://github.com/gentoo-mirror/mv.git masters: gentoo volatile: True vapoursynth location: /var/db/repos/vapoursynth sync-type: git sync-uri: https://github.com/gentoo-mirror/vapoursynth.git masters: gentoo volatile: True Installed sets: @dbuspkg, @fonts, @games, @librsvg, @localrepo, @phone, @subtitles, @themes, @vm, @wm, @xfce ACCEPT_KEYWORDS="amd64" ACCEPT_LICENSE="@FREE" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-march=bdver2 -O2 -pipe" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /etc/portage/savedconfig/sys-kernel/linux-firmware /usr/bin/startx /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/thumbnailers/ffmpegthumbnailer.thumbnailer /usr/share/thumbnailers/imagemagick-pdf.thumbnailer" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo" CXXFLAGS="-march=bdver2 -O2 -pipe" DISTDIR="/var/cache/distfiles" EMERGE_DEFAULT_OPTS="--usepkg --binpkg-respect-use=y" ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME" FCFLAGS="-march=bdver2 -O2 -pipe" FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr" FFLAGS="-march=bdver2 -O2 -pipe" GENTOO_MIRRORS="https://mirror.leaseweb.com/gentoo/" INSTALL_MASK="/etc/sysctl.d/ /etc/systemd/ /lib/systemd/ /usr/lib/sysctl.d/ /usr/lib/systemd/ /run/systemd/" LANG="fr_FR.UTF-8" LDFLAGS="-Wl,-O1 -Wl,--as-needed" LEX="flex" LINGUAS="en fr" MAKEOPTS="-j5" PKGDIR="/var/cache/binpkgs" PORTAGE_CONFIGROOT="/" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git" PORTAGE_TMPDIR="/var/tmp" SHELL="/bin/bash" USE="X a52 aac acl acpi aio alsa amd64 bzip2 cairo cdda cdr cet cli crypt cryptsetup cups dbus device-mapper dri dts dvd elogind encode exif fam fftw flac fortran gdbm gif gnat_2021 gpm graphite gtk hardened iconv icu ipv6 jpeg libglvnd libnotify libtirpc lto lvm lz4 lzma lzo mad mp3 mp4 ncurses nfs nls nptl ogg opengl openmp openssl opus pam pango pcre pdf pgo pie png policykit readline sdl seccomp sftp split-usr ssh ssl ssp startup-notification svg system-av1 system-binutils system-cairo system-clang system-cmark system-compress system-digest system-ffmpeg system-harfbuzz system-heimdal system-icu system-images system-jpeg system-jsoncpp system-lcms system-leveldb system-libevent system-libmspack system-libs system-libvpx system-libyaml system-llvm system-lua system-lz4 system-nss system-openjpeg system-pixman system-png system-renpy system-snappy system-sqlite system-tbb system-uulib system-vpx system-zlib test-rust tiff truetype udev udisks unicode upower usb vaapi vdpau verify-sig vorbis webp wxwidgets x264 xattr xcb xml xtpax xv xvid zlib zstd" ABI_X86="64" ADA_TARGET="gnat_2021" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx f16c fma3 fma4 mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 xop" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" L10N="fr" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-4 php8-0" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_10" PYTHON_TARGETS="python3_10" QEMU_SOFTMMU_TARGETS="aarch64 arm ppc ppc64 i386 x86_64" QEMU_USER_TARGETS="aarch64 arm armeb ppc ppc64 i386 x86_64" RUBY_TARGETS="ruby27 ruby30" USERLAND="GNU" VIDEO_CARDS="radeon r600" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account" Unset: ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, LC_ALL, LD, LFLAGS, LIBTOOL, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Created attachment 854496 [details] games-emulation/jgrf-1.0.0 (build log)
Created attachment 854498 [details] games-emulation/jgrf-1.0.0 (build log) (-D_FORTIFY_SOURCE=2 -U_GLIBCXX_ASSERTIONS)
Thanks, it's FORTIFY_SOURCE=3 then. Could you grab a backtrace when it dies? (Build with debugging symbols per https://wiki.gentoo.org/wiki/Debugging#Per-package then gdb --args jollygood -v -w -c mednafen "Final Fantasy VI.sfc", then type 'r', enter, then 'bt' & enter when it crashes).
Created attachment 854500 [details] games-emulation/jgrf-1.0.0 (gdb log)
Any tips how to reproduce this? I built jgrf and mednafen-jg with -DFORTIFY_SOURCE=3 on both glibc and musl systems without any luck.
(In reply to orbea from comment #5) > Any tips how to reproduce this? I built jgrf and mednafen-jg with > -DFORTIFY_SOURCE=3 on both glibc and musl systems without any luck. -D_FORTIFY_SOURCE=3 (note the _)
> -D_FORTIFY_SOURCE=3 (note the _) Oh, my bad. I can reproduce this on my glibc system now, but not my musl.
(In reply to orbea from comment #7) > > -D_FORTIFY_SOURCE=3 (note the _) > Oh, my bad. I can reproduce this on my glibc system now, but not my musl. Yeah, unfortunately, musl doesn't support fortification. There's sys-libs/fortify-headers but iirc it basically implements F_S=1 (not 2 or 3) and it has aliasing issues. Alpine patches it in to the toolchain by default but we don't for musl because of those bugs in the implementation.
A PR was created with new bug fix releases for jgrf and prosystem-jg which was also discovered to have the same issue. @David Duchesne I would appreciate if you can confirm if the fix also work for you. Also you may want to try bsnes-jg which is the default super famicom core and is more accurate than faust in mednafen-jg. Although its also much slower which may be an issue depending on your hardware, this is why faust is there.
Hi orbea, Thanks. games-emulation/jgrf-1.0.1 fixed the issue! Unfortunately, bsnes-jg core crashes (all other cores works including mednafen of course, I can't test jollycv & prosystem because I don't have any game for them) Here is the log for bsnes-jg crash (I tried with different games just to make sure) : jollygood -v -w -c bsnes Final\ Fantasy\ VI.sfc d: Moving Averge set: 60.098812 fps, 1600 spf (old: 0, diff: 1600) i: Core: bsnes (bsnes-jg 1.1.0) d: Core System: snes d: Core Path: /usr/lib64/jollygood/bsnes.so d: Core Asset Path: /usr/share/jollygood/bsnes d: Creating window with dimensions: 878 x 672 d: Screen base FPS set: 60fps i: Video: OpenGL 4.3 (Core Profile) Mesa 22.2.5 i: Audio: 48000Hz Stereo, Speex 3 w: Input configuration file not found: /home/duchesne/.config/jollygood/input_snes.ini i: Emulated Input 1: snespad1, SNES Controller, 0 axes, 12 buttons i: Emulated Input 2: snespad2, SNES Controller, 0 axes, 12 buttons i: Emulated Input 3: unconnected, Unconnected, 0 axes, 0 buttons i: Emulated Input 4: unconnected, Unconnected, 0 axes, 0 buttons i: Emulated Input 5: unconnected, Unconnected, 0 axes, 0 buttons d: No cheat file: /home/duchesne/.local/share/jollygood/cheats/bsnes/Final Fantasy VI.json d: Screen base FPS set: 60fps /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/stl_vector.h:1123: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = float; _Alloc = std::allocator<float>; reference = float&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.
(In reply to David Duchesne from comment #10) > Hi orbea, > Thanks. games-emulation/jgrf-1.0.1 fixed the issue! > Unfortunately, bsnes-jg core crashes (all other cores works including > mednafen of course, I can't test jollycv & prosystem because I don't have > any game for them) > > Here is the log for bsnes-jg crash (I tried with different games just to > make sure) : > > jollygood -v -w -c bsnes Final\ Fantasy\ VI.sfc > d: Moving Averge set: 60.098812 fps, 1600 spf (old: 0, diff: 1600) > i: Core: bsnes (bsnes-jg 1.1.0) > d: Core System: snes > d: Core Path: /usr/lib64/jollygood/bsnes.so > d: Core Asset Path: /usr/share/jollygood/bsnes > d: Creating window with dimensions: 878 x 672 > d: Screen base FPS set: 60fps > i: Video: OpenGL 4.3 (Core Profile) Mesa 22.2.5 > i: Audio: 48000Hz Stereo, Speex 3 > w: Input configuration file not found: > /home/duchesne/.config/jollygood/input_snes.ini > i: Emulated Input 1: snespad1, SNES Controller, 0 axes, 12 buttons > i: Emulated Input 2: snespad2, SNES Controller, 0 axes, 12 buttons > i: Emulated Input 3: unconnected, Unconnected, 0 axes, 0 buttons > i: Emulated Input 4: unconnected, Unconnected, 0 axes, 0 buttons > i: Emulated Input 5: unconnected, Unconnected, 0 axes, 0 buttons > d: No cheat file: /home/duchesne/.local/share/jollygood/cheats/bsnes/Final > Fantasy VI.json > d: Screen base FPS set: 60fps > /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/stl_vector.h:1123: > std::vector<_Tp, _Alloc>::reference std::vector<_Tp, > _Alloc>::operator[](size_type) [with _Tp = float; _Alloc = > std::allocator<float>; reference = float&; size_type = long unsigned int]: > Assertion '__n < this->size()' failed. You have excellent (terrible) luck. This new one is -D_GLIBCXX_ASSERTIONS.
... backtrace again please, too.
Created attachment 854624 [details] bsnes-jg-1.1.0 (build log gdb)
> You have excellent (terrible) luck. This new one is -D_GLIBCXX_ASSERTIONS. Indeed, it starts fine if compiled with -D_GLIBCXX_ASSERTIONS. Cheers.
Created attachment 854654 [details] games-emulation/jgrf (gdb on an other arch (core2) with different gpu) So, 1.0.1 fixed the issue with FORTIFY on my desktop. (bdver2) But for some reason, the same version crashes on my laptop (core2) (See gdb log) w: Failed to create glcontext: No OpenGL context has been made current jollygood: ../libepoxy-1.5.10/src/dispatch_common.c:872: epoxy_get_proc_address: Assertion `0 && "Couldn't find current GLX or EGL context.\n"' failed. As it looks an entire different issue, should I open an other bug ? It seems related to libepoxy (assertion again?) but I don't know what's causing that. Both system are identical config wise except of course cflags & video cards, for my laptop it is: CFLAGS="-march=core2 -O2 -pipe" VIDEO_CARDS="intel"
I can reproduce the bsnes-jg issue with both glibc and musl by adding -D_GLIBCXX_ASSERTIONS to the CPPFLAGS. The libepoxy issue seems to be at a deeper level than jgrf. I don't know, but maybe its even in mesa? You might be able to start it by setting video API that jollygood uses, see --video in --help or in the man page, perhaps --video 2 would work?
What OpenGL version does your intel chip support? $ glxinfo | grep Core
I updated the PR with a bug fix release for bsnes-jg that should fix the assert with -D_GLIBCXX_ASSERTIONS.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3537e031216808bf98fa5c220593d0c390dbe4e1 commit 3537e031216808bf98fa5c220593d0c390dbe4e1 Author: orbea <orbea@riseup.net> AuthorDate: 2023-02-25 18:09:47 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2023-02-25 22:23:22 +0000 games-emulation/jgrf: Add 1.0.1 + Remove 1.0.0 Bug fix release for a buffer overflow with -D_FORTIFY_SOURCE=3 on glibc systems. Closes: https://bugs.gentoo.org/896382 Signed-off-by: orbea <orbea@riseup.net> Signed-off-by: Sam James <sam@gentoo.org> games-emulation/jgrf/Manifest | 2 +- games-emulation/jgrf/{jgrf-1.0.0.ebuild => jgrf-1.0.1.ebuild} | 0 2 files changed, 1 insertion(+), 1 deletion(-) Additionally, it has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f084399b8a20ec5871f6ef116f975cc434762c54 commit f084399b8a20ec5871f6ef116f975cc434762c54 Author: orbea <orbea@riseup.net> AuthorDate: 2023-02-25 22:17:07 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2023-02-25 22:23:24 +0000 games-emulation/bsnes-jg: Add 1.1.1 + Remove 1.1.0 Bug fix release for an assert with -D_GLIBCXX_ASSERTIONS Bug: https://bugs.gentoo.org/896382 Signed-off-by: orbea <orbea@riseup.net> Closes: https://github.com/gentoo/gentoo/pull/29791 Signed-off-by: Sam James <sam@gentoo.org> games-emulation/bsnes-jg/Manifest | 2 +- .../bsnes-jg/{bsnes-jg-1.1.0.ebuild => bsnes-jg-1.1.1.ebuild} | 0 2 files changed, 1 insertion(+), 1 deletion(-) https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fdeec5aa5183326e523bd708dec9c862b5b07982 commit fdeec5aa5183326e523bd708dec9c862b5b07982 Author: orbea <orbea@riseup.net> AuthorDate: 2023-02-25 18:25:07 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2023-02-25 22:23:23 +0000 games-emulation/prosystem-jg: Add 1.5.2 + Remove 1.5.1 Bug fix release for a buffer overflow with -D_FORTIFY_SOURCE=3 on glibc systems. Bug: https://bugs.gentoo.org/896382 Signed-off-by: orbea <orbea@riseup.net> Signed-off-by: Sam James <sam@gentoo.org> games-emulation/prosystem-jg/Manifest | 2 +- .../{prosystem-jg-1.5.1.ebuild => prosystem-jg-1.5.2.ebuild} | 0 2 files changed, 1 insertion(+), 1 deletion(-)