Skip to content

Builds of RSDKv4 Crash with -Wp,-D_FORTIFY_SOURCE=3 crash when loading Modded Content #440

@Sewer56

Description

@Sewer56

Before opening this issue, I ensure that...

  • I have read the FAQ and confirmed my issue is not mentioned in it.
  • I have checked both open and closed issues and confirmed this bug has not already been reported.
  • I am not asking for tech support (e.g. game closing on startup, error when trying to build, etc).
  • I am not asking for modding support or reporting a bug in a specific mod; this bug either occurs without mods enabled or is directly related to the mod loader.
  • This bug is not related to any unofficial fork/port of the decompilation, and any issues with those should be kept in the appropriate repository.

Expected Behavior

Loading a stage with mod(s) enabled should not crash the process.

Actual Behavior

Loading a stage with mod(s) enabled crashes the process.

Steps to Reproduce

For convenience, I provide a sample PKGBUILD for Arch based distros below:

[On other Distros you can use CLI as usual]

pkgname=rsdkv4
pkgver=1.3.2
pkgrel=1
pkgdesc="Complete decompilation of Sonic 1 & Sonic 2 (2013) & Retro Engine (v4)"
arch=(x86_64)
url="https://github.com/Rubberduckycooly/Sonic-1-2-2013-Decompilation"
license=(custom)
depends=(glibc gcc-libs sdl2 glew libvorbis libglvnd)
makedepends=(git cmake)
source=("rsdkv4::git+https://github.com/Rubberduckycooly/Sonic-1-2-2013-Decompilation.git#tag=${pkgver}")
sha256sums=('SKIP')

prepare() {
  cd rsdkv4
  # Initialize and update submodules as per the original repository configuration
  git submodule update --init --recursive
}

build() {
  export CFLAGS="-march=native -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection"
  export CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
  export LDFLAGS="-flto=auto"

  # We set RETRO_FORCE_CASE_INSENSITIVE in case of improper use of Mod API
  # by people making mods; an end user should have something that 'just works'
  # out of the box after all.
  cmake -B build -S "rsdkv4" -DRETRO_FORCE_CASE_INSENSITIVE=on
  cmake --build build --config release
}

package() {
  # Install the main binary
  install -D build/RSDKv4 -t "${pkgdir}/usr/bin"
  # Symlink to lowercase
  ln -s /usr/bin/RSDKv4 "${pkgdir}/usr/bin/rsdkv4"

  # Install the license file
  install -D rsdkv4/LICENSE.md -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

This can be used with any Arch based distro with makepkg -si, or makepkg -siCf to force a clean rebuild.

In this PKGBUILD I specifically set the CFLAGS, CXXFLAGS and LDFLAGS explicitly for testing purposes.
I set them to the default values you would encounter in /etc/makepkg.conf on any Arch based distro.


When building with -Wp,-D_FORTIFY_SOURCE=3 the Application crashes.
This is likely indicative of a buffer overrun somewhere in RSDKv4 decomp.

I don't currently know where; my experience with C stuff is very little and
I'm kind of in a rush to get SHC2024 entry evals done. 😅

Running with AddressSanitizer/asan, there's an unrelated buffer overrun on boot,
so I haven't gotten around to catching the actual issue (yet).


Reproduction Steps:

  1. Enable a mod
  2. Reboot game
  3. Start a stage with modified assets

S314P can be used for testing, but I've experienced this in just about every mod.

Screenshots

No response

Log File

No response

Decompilation Version

1.3.2

Game

Sonic 2

Game Version

Mobile (Pre-Sega Forever)

Game Revision

No response

Platform

Linux x64 (Linux 6.11.0-5-cachyos-lto, x86-64-v3)

Additional Comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions