ps2homebrew / hdl-dump

Install games in HDLoader format to APA-formatted hard drive
122 stars 25 forks source link

[ISSUE]: Linux - inject_dvd and inject_cd have segmentation fault after injecting games #75

Closed xeons closed 11 months ago

xeons commented 1 year ago

Checks

Describe the issue

The games seem to be fully installed after the crash occurs, but it would be nice if the process didn't segfault at all. I don't know enough about this utility to know if corruption might be occurring. I'm also not an expert when it comes to threading on Linux, but this seems like some kind of race condition.

hdl_toc lists the games after it crashes, and I verified that the md5sum of the game I installed matches by extracting the ISO back out.

OS: Manjaro 23 Kernel: 6.3.5-2-MANJARO Hard Drive: 2 TB Western Digital (total 1907712MB, used 234624MB, available 1673088MB, sector size 512)

Command:

./hdl_dump inject_dvd /dev/sdb "Soulcalibur III (USA)" "/home/xeon/Downloads/PS2GAMES/Soulcalibur III (USA).iso" SLUS_212.16
I've attached the backtrace from gdb after enabling debugging symbols.

#0  __new_sem_wait_fast (definitive_result=0, sem=0x90) at /usr/src/debug/glibc/glibc/nptl/sem_waitcommon.c:136
#1  __new_sem_wait (sem=sem@entry=0x90) at sem_wait.c:39
#2  0x000055784e6585fa in thd_close (iin=0x0) at thd_iin.c:185
#3  0x000055784e64ad3b in inject (config=config@entry=0x55784ff432a0, output=, name=, input=0x7fff6348b191 "/home/xeon/Downloads/PS2GAMES/Soulcalibur III (USA).iso", startup=startup@entry=0x7fff6348b1c9 "SLUS_212.16", 
    compat_flags=compat_flags@entry=0 '\000', dma=1088, is_dvd=1, is_hidden=0, slice_index=-1, pgs=0x55784ff43510) at hdl_dump.c:1127
#4  0x000055784e6498ee in main (argc=, argv=0x7fff634896a8) at hdl_dump.c:2115

Console model

N/A

xeons commented 1 year ago

I figured it out. This commit involving ZSO broke it.

https://github.com/ps2homebrew/hdl-dump/commit/d0242788997279f0e7d8128393cb032c8f7bcd46#diff-0c451c47a25691658bea3d0039c0f4c3eebcedf82466213196da930c0f75b5f9

It tries to call close() on the wrong iin_t struct. There's also a chance that iin_zso will be NULL if iin_probe returns an error for the ZSO file.

I also fail to see why the user should be forced to keep the original file in order to write out a ZSO, and the way that it's being done is rather hacky.

israpps commented 1 year ago

I also fail to see why the user should be forced to keep the original file in order to write out a ZSO, and the way that it's being done is rather hacky.

IIRC it was done intentionally so hdl_dump and most automated tools based on it can pull the needed info from the iso without addind ZSO support to hdl_dump

xeons commented 1 year ago

I also fail to see why the user should be forced to keep the original file in order to write out a ZSO, and the way that it's being done is rather hacky.

IIRC it was done intentionally so hdl_dump and most automated tools based on it can pull the needed info from the iso without addind ZSO support to hdl_dump

I'm going to see if I can add native ZSO support, so that way there aren't these hacks.

bitrot-alpha commented 1 year ago

I'm using OpenSUSE Tumbleweed. I get a segfault with 9cd71a4 build right as the game finishes copying, or at least it seems to finish.

I've tried using both OPL Beta 1.2.0 (with NBD) and hdl_svr_093.elf to copy a game to the PS2 HDD over network. I haven't been able to get the game I've tried copying to run, I just end up with the white debug screen from OPL. I haven't tried copying back the game from the HDD to check if the checksums actually match.

Dmesg output:

[ 5735.893064] show_signal_msg: 49 callbacks suppressed
[ 5735.893069] hdl_dump[7536]: segfault at 90 ip 00007f6b9ddaf13d sp 00007ffd006d4450 error 4 in libc.so.6[7f6b9dd3f000+169000] likely on CPU 3 (core 1, socket 0)
[ 5735.893082] Code: ff ff eb 98 e8 82 06 09 00 0f 1f 40 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa 90 90 53 48 89 fb e8 01 f0 ff ff <48> 8b 03 85 c0 74 14 48 8d 50 ff f0 48 0f b1 13 75 09 31 c0 5b c3

Is there a Linux build from before the ZSO commit, or do I need to download PS2SDK and build myself?

israpps commented 1 year ago

I'm using OpenSUSE Tumbleweed. I get a segfault with 9cd71a4 build right as the game finishes copying, or at least it seems to finish.

I've tried using both OPL Beta 1.2.0 (with NBD) and hdl_svr_093.elf to copy a game to the PS2 HDD over network. I haven't been able to get the game I've tried copying to run, I just end up with the white debug screen from OPL. I haven't tried copying back the game from the HDD to check if the checksums actually match.

Dmesg output:

[ 5735.893064] show_signal_msg: 49 callbacks suppressed
[ 5735.893069] hdl_dump[7536]: segfault at 90 ip 00007f6b9ddaf13d sp 00007ffd006d4450 error 4 in libc.so.6[7f6b9dd3f000+169000] likely on CPU 3 (core 1, socket 0)
[ 5735.893082] Code: ff ff eb 98 e8 82 06 09 00 0f 1f 40 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa 90 90 53 48 89 fb e8 01 f0 ff ff <48> 8b 03 85 c0 74 14 48 8d 50 ff f0 48 0f b1 13 75 09 31 c0 5b c3

Is there a Linux build from before the ZSO commit, or do I need to download PS2SDK and build myself?

White screen means main game executable was not found.

Most likely corrupted game

xeons commented 11 months ago

I'm going to close my own bug report since I fixed it myself with that pull request. :smile:

Joseph-DiGiovanni commented 1 month ago

I'm getting "Segmentation faulting" after the game finished transferring locally with just a normal ISO on the last release and the latest commit