hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
11.39k stars 2.19k forks source link

Crashing while running Luadev r0 (lua interpreter) #19085

Open BrownNPC opened 6 months ago

BrownNPC commented 6 months ago

Game or games this happens in

Luadev r0 (lua interpreter)

What area of the game / PPSSPP

PPSSPP no longer supports this old homebrew lua interpreter It used to work on version 1.9.3 and it does work on jpcsp.

How to reproduce:

git clone https://github.com/jcnmsg/luadev-r0-psp.git
mkdir ./luadev-r0-psp/projects/hello-world-test
cp ./luadev-r0-psp/EBOOT.PBP ./luadev-r0-psp/projects/hello-world-test/

create a file script.lua in ./luadev-r0-psp/projects/hello-world-test/

blue = color.new(0,0,255) 
white = color.new(255, 255, 255)
black = color.new(0, 0, 0)

screen.print(10, 10, "Hello world!" , 0.6, blue, blue)
screen.print(10, 26, "This is my first program and it runs on the PSP!" , 0.4, white, black)

screen.flip()

while true do
    screen.waitvblankstart()
end

start EBOOT.PBP in ./luadev-r0-psp/projects/hello-world-test/EBOOT.PBP

What should happen

PPSSPP shouldn't crash and handle the unimplemented features.

Logs

13:44:177 user_main    E[FILESYS]: FileSystems/DirectoryFileSystem.cpp:58 DirectoryFileSystem::OpenFile('/syslib.prx'): FAILED, 2 - access = 1 ''
13:44:177 user_main    E[LOADER]: HLE/sceKernelModule.cpp:2030 80010002=sceKernelLoadModule(umd0:/syslib.prx, 00000000, 00000000): file does not exist
13:44:178 user_main    E[FILESYS]: FileSystems/DirectoryFileSystem.cpp:58 DirectoryFileSystem::OpenFile('/recovery.lua'): FAILED, 2 - access = 1 ''
13:44:188 user_main    E[FILESYS]: FileSystems/DirectoryFileSystem.cpp:58 DirectoryFileSystem::OpenFile('/recovery.lue'): FAILED, 2 - access = 1 ''
13:44:208 user_main    E[FILESYS]: FileSystems/DirectoryFileSystem.cpp:58 DirectoryFileSystem::OpenFile('/script.lue'): 
FAILED, 2 - access = 1 ''

Platform

Linux / BSD

Mobile device model or graphics card (GPU)

GT 720

PPSSPP version affected

PPSSPP v1.17.1 [flatpak]

Last working version

1.9.3

Graphics backend (3D API)

OpenGL / GLES

Checklist

anr2me commented 6 months ago

Hmm.. this is on Windows: image image

PS: i can't download the latest devbuild because the list didn't shows up on my firefox, so i use the latest version i had nevermind, it's just too slow (Downloading the latest ppsspp devbuild with 7.7 KB/s speed LOL my ISP probably throttling my connection again), the list shows up much later

hrydgard commented 6 months ago

Hm, not sure why the devbuilds server is slow :( I'll look into that. It's a temporary hosting solution anyway, but it should work okay.

LunaMoo commented 6 months ago

I'm not on the very latest, but still 1.17.1 and it works, however it can't find the script when placed inside projects folder, the binary from the site loads it from it's own main directory. Edit: and that seems to be expected behaviour seeing the guide mentions "Copy the EBOOT.PBP file to your new project folder:", but that guide is also inaccurate as the project should be memstick\PSP\GAME*your project name here*\ which has both EBOOT.PBP and script.lua files.

Edit2: and here: works fine on buildbot version as well: runs fine

Also it doesn't crash when script is missing in it's folder, it just shows it's own error: while script missing

So I guess you guys forget that homebrew is special case and needs to be launched from within "memstick\PSP\GAME" (and yeah, real PSP wouldn't even see it if it was outside of that folder, PPSSPP can load most games from any folder you want, but homebrew are special case, they use hardcoded paths outside of it's own container and for safety it's a golden rule to only launch them from correct folder structure).

This whole point on the guide for using this homebrew is wrong:

5. On your emulator go to File > Load and load the EBOOT.PBP in your project folder. You should see the result:

Should be changed to:

5. Move your project folder consisting of EBOOT.PBP and script.lua into "memstick\PSP\GAME" and launch it from homebrew menu on PPSSPP.

I assume the information about "Last working version" being "1.9.3" comes from the linked guide itself as there should have been no behaviour change, the person writing that guide probably just stored it in correct folder to begin with and as such saw no issues that could arise from storing it elsewhere.

anr2me commented 6 months ago

I'm not on the very latest, but still 1.17.1 and it works, however it can't find the script when placed inside projects folder, the binary from the site loads it from it's own main directory. Edit: and that seems to be expected behaviour seeing the guide mentions "Copy the EBOOT.PBP file to your new project folder:", but that guide is also inaccurate as the project should be memstick\PSP\GAMEyour project name here\ which has both EBOOT.PBP and script.lua files.

Edit2: and here: works fine on buildbot version as well: runs fine

Also it doesn't crash when script is missing in it's folder, it just shows it's own error: while script missing

So I guess you guys forget that homebrew is special case and needs to be launched from within "memstick\PSP\GAME" (and yeah, real PSP wouldn't even see it if it was outside of that folder, PPSSPP can load most games from any folder you want, but homebrew are special case, they use hardcoded paths outside of it's own container and for safety it's a golden rule to only launch them from correct folder structure).

This whole point on the guide for using this homebrew is wrong:

5. On your emulator go to File > Load and load the EBOOT.PBP in your project folder. You should see the result:

Should be changed to:

5. Move your project folder consisting of EBOOT.PBP and script.lua into "memstick\PSP\GAME" and launch it from homebrew menu on PPSSPP.

I assume the information about "Last working version" being "1.9.3" comes from the linked guide itself as there should have been no behaviour change, the person writing that guide probably just stored it in correct folder to begin with and as such saw no issues that could arise from storing it elsewhere.

Based on my logs, I did put the hello-world-test folder inside PSP/GAME folder, but i use the File->Load menu to launch the EBOOT.PBP (didn't know that homebrew has it's own launcher)

Edit: Opening it from Homebrew menu have the same issue in my case, but i haven't DL the latest devbuild as it's too slow and failed in the middle of DL. image image

Edit2: i was disabling "Ignore bad memory access" before in order to catch the first crash, if i enable it, it will only renders black screen, with a few bad address in the logs image Same issue using the latest artifact, and the latest release version at ppsspp.org too. Strangely mine is showing a different title id than yours.

LunaMoo commented 6 months ago

Homebrew lacks proper gameID, so it's fakeID generated per folder name.

I will check once I get home, but I don't think I really have any settings that would make it work, more likely something is breaking it, maybe even lengthy folder name, I kept mine short.

BrownNPC commented 6 months ago

SO, I made a new directory, inside this folder I have the EBOOT file as well as the script.lua file with the hello world program. I ran the eboot by running xdg-open ./EBOOT.PBP then I get the error in my bash console:

21:57:247 user_main    E[FILESYS]: FileSystems/DirectoryFileSystem.cpp:58 DirectoryFileSystem::OpenFile('/syslib.prx'): FAILED, 30 - access = 11 ''
21:57:257 user_main    E[FILESYS]: FileSystems/DirectoryFileSystem.cpp:58 DirectoryFileSystem::OpenFile('/syslib.prx'): FAILED, 2 - access = 1 ''
21:57:257 user_main    E[LOADER]: HLE/sceKernelModule.cpp:2030 80010002=sceKernelLoadModule(umd0:/syslib.prx, 00000000, 00000000): file does not exist
21:57:258 user_main    E[FILESYS]: FileSystems/DirectoryFileSystem.cpp:58 DirectoryFileSystem::OpenFile('/recovery.lua'): FAILED, 2 - access = 1 ''
21:57:267 user_main    E[FILESYS]: FileSystems/DirectoryFileSystem.cpp:58 DirectoryFileSystem::OpenFile('/recovery.lue'): FAILED, 2 - access = 1 ''
21:57:287 user_main    E[FILESYS]: FileSystems/DirectoryFileSystem.cpp:58 DirectoryFileSystem::OpenFile('/script.lue'): FAILED, 2 - access = 1 ''

Then I tried to run the windows version 1.9.3 using wine, and it ran properly.

On the latest windows version running through wine I get this

Screenshot_20240423_183423

The folder is inside memstick/psp/game just like Luna stated.

LunaMoo commented 6 months ago

Probably something specific you guys are doing, I even tried latest artifact and many usually game breaking settings and I couldn't find any way or setting to reproduce the crash.

Even the other examples like ball drop works fine: LUAD00976_00000

And v0 for me at the address you both get that illegal read is normal looking address. diss lua

I didn't bother following the guide through, meaning I also didn't used git for cloning it, just web browser download.

anr2me commented 6 months ago

I didn't bother following the guide through, meaning I also didn't used git for cloning it, just web browser download.

Same with me :) i don't have git on this freshly installed windows 11, so i only downloaded the EBOOT.PBP using browser and created the script.lua

I also extract ppsspp files into a new folder with everything as default, still got the same error.

Edit: if i removed the script.lua file it works fine, so i guess something in the script causing it to crash image

LunaMoo commented 6 months ago

I think I found the problem. I went completely clean and finally reproduced your crash. Then I just copied my psp fonts and it fixed it. So there's something about provided font or it's memory allocation which this homebrew doesn't like. It will work with original PSP fonts.

hrydgard commented 6 months ago

Do luadev apps have some specific identifier, like PARAM.SFO id or something? We could warn about this.

Alternatively, there might be some other kind of workaround we can do. Tagging to take a look for the next upcoming version.

LunaMoo commented 6 months ago

Probably not, but since the app works and only breaks when loading hardcoded filename of script.lua with non default PSP fonts, a warning could happen on "script.lua" read, maybe also only for homebrew.

Through I find it weird that the app bundle comes with software to create/customize PSP fonts and doesn't support custom one we have in PPSSPP.

anr2me commented 6 months ago

It's kinda strange, for example i use ppsspp v.1.17.1 release version as the base, if i overwrite the ltn0.pgf ~ ltn15.pgf with the one from the latest artifact it works fine (not crashing), meanwhile the latest artifact nor the release version, both didn't works (crashed) with the fonts it came with O.o it even crashed with an empty script.lua file

Edit: nevermind, need more testing, i'm not sure which version the fonts i had on the folder with the latest artifact executable, when i tried to extract the font from the latest artifact to a new folder and use those fonts on the release version, it crashed again :( may be the fonts were from 1.9.3 which works fine with 1.17.1 executable when changing version i usually copy the executable a long with the assets folder, not sure why it works before but when i try on a new folder didn't works

I guess the only way to make it works is by using latin fonts from 1.9.3 or before 1.11.0 (as alternative to real PSP fonts), only need to replace the ltn0.pgf to be precise.

Edit2: The ltn0.pgf from this commit https://github.com/hrydgard/ppsspp/commit/06b0e33839b4260caa7f950df7e7a19961395e70 is the last working version, and started to crash from this commit https://github.com/hrydgard/ppsspp/commit/737e0d55d4a06cb026ec453010e1860ecc23df97 may be @nassau-tk knew what's the difference between those commits.

nassau-tk commented 6 months ago

Probaly, It was created unknown user for 1.9.3. My font was created for 1.11.0 release.

anr2me commented 6 months ago

Probaly, It was created unknown user for 1.9.3. My font was created for 1.11.0 release.

Both commits (https://github.com/hrydgard/ppsspp/commit/06b0e33839b4260caa7f950df7e7a19961395e70 and https://github.com/hrydgard/ppsspp/commit/737e0d55d4a06cb026ec453010e1860ecc23df97) were made by you, right? But only one of them didn't crashed.

And the last working version should be 1.10.3 instead of 1.9.3

nassau-tk commented 6 months ago

Yes, Thats right! I will check it!

nassau-tk commented 6 months ago

[What's the difference between November 1st and November 23rd?]

Probably, The converter I am using is different.

06b0e33 01.Nov. ==> ttf2pgfj.exe 767e0d5 23.Nov. ==> pgftool

And, When I compared it with the hex editor, [01Nov] was almost the same as the original, but [23.Nov] had a unique value. *Both characters included are exactly the same as the original.

But, I think [23.Nov] is working on PPSSPP. And, ttf2pgfj.exe can't create pgf correctly.

By the way, what is Luadev r0 ????

BrownNPC commented 6 months ago

By the way, what is Luadev r0 ????

Lua interpreter for the psp. it allows u to write apps for it in lua