Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create-fself crashes with SIGSEGV when linking with --gc-sections --as-needed #6

Open
glebm opened this issue Nov 20, 2022 · 1 comment

Comments

@glebm
Copy link

glebm commented Nov 20, 2022

After linking with --gc-sections --as-needed, create-fself crashes with SIGSEGV at OELFGenProgramHeaders.go:116:

FAILED: devilutionx.self /home/gleb/devilutionX/build-ps4/devilutionx.self 
cd /home/gleb/devilutionX/build-ps4 && /usr/bin/cmake -E env OO_PS4_TOOLCHAIN=/opt/pacbrew/ps4/openorbis /opt/pacbrew/ps4/openorbis/bin/create-fself -in=devilutionx -out=devilutionx.oelf --eboot eboot.bin --paid 0x3800000000000035 --authinfo 000000000000000000000000001C004000FF000000000080000000000000000000000000000000000000008000400040000000000000008000000000000000080040FFFF000000F000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x4bd64b]

goroutine 1 [running]:
github.com/OpenOrbis/create-fself/pkg/oelf.(*OrbisElf).GenerateProgramHeaders(0xc000185680)
	/home/cpasjuste/dev/pacbrew-packages/ps4-openorbis/create-fself/src/create-fself-30d2e10507f55124cf21e85e19825482e4f93c87/pkg/oelf/OELFGenProgramHeaders.go:116 +0x3ab
main.main()
	/home/cpasjuste/dev/pacbrew-packages/ps4-openorbis/create-fself/src/create-fself-30d2e10507f55124cf21e85e19825482e4f93c87/cmd/create-fself/main.go:94 +0x517
ninja: build stopped: subcommand failed.

The crash happens here:

dataSize := (dataSection.Offset - procParamSection.Offset) + dataSection.Size

More log: https://gist.githubusercontent.com/glebm/49a29bfc641ea3c844cadd08ef18df68/raw/c2ac2268dba8f3c6ec4b69fca7ec4eecf8dbbc33/gistfile1.txt

@glebm
Copy link
Author

glebm commented Nov 20, 2022

Steps to reproduce this crash:

# Install system packages and prepare the PS4 toolchain:
sudo apt-get install -y wget cmake git gettext smpq
wget https://github.com/PacBrew/pacbrew-pacman/releases/download/v1.1/pacbrew-pacman-1.1.deb
sudo dpkg -i pacbrew-pacman-1.1.deb
sudo pacbrew-pacman -Sy
sudo pacbrew-pacman --noconfirm -S ps4-openorbis ps4-openorbis-portlibs
echo "#include <endian.h>" | sudo tee /opt/pacbrew/ps4/openorbis/include/sys/endian.h

# Clone DevilutionX
git clone https://github.com/diasurgical/devilutionX.git
cd devilutionX

# Disable the workaround that prevents the crash:
sed -i 's/ AND NOT PS4//' CMakeLists.txt

# Build, will crash here:
Packaging/ps4/build.sh

For the above to work, the changes in PacBrew/ps4-openorbis#7 need to be released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant