libretro / ludo

A libretro frontend written in golang
https://ludo.libretro.com/
GNU General Public License v3.0
590 stars 68 forks source link

retro_serialize segmentation violation #184

Closed kivutar closed 2 years ago

kivutar commented 5 years ago

Happened a few times on RPi with fceumm:

Mar 24 02:59:30 LudOS ludo[633]: 2019/03/24 02:59:30 [Core]: Game loaded: /storage/roms/Nintendo - Nintendo Entertainment System/Akira (Japan).zip
Mar 24 04:53:49 LudOS ludo[633]: fatal error: unexpected signal during runtime execution
Mar 24 04:53:49 LudOS ludo[633]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x4 pc=0x76f27e3c]
Mar 24 04:53:49 LudOS ludo[633]: runtime stack:
Mar 24 04:53:49 LudOS ludo[633]: runtime.throw(0x3943a7, 0x2a)
Mar 24 04:53:49 LudOS ludo[633]:         /home/travis/.gimme/versions/go1.11.linux.amd64/src/runtime/panic.go:608 +0x5c
Mar 24 04:53:49 LudOS ludo[633]: runtime.sigpanic()
Mar 24 04:53:49 LudOS ludo[633]:         /home/travis/.gimme/versions/go1.11.linux.amd64/src/runtime/signal_unix.go:374 +0x22c
Mar 24 04:53:49 LudOS ludo[633]: goroutine 1 [syscall, locked to thread]:
Mar 24 04:53:49 LudOS ludo[633]: runtime.cgocall(0x2d09e0, 0x1432e04, 0x29)
Mar 24 04:53:49 LudOS ludo[633]:         /home/travis/.gimme/versions/go1.11.linux.amd64/src/runtime/cgocall.go:128 +0x5c fp=0x1432de8 sp=0x1432dd0 pc=0x31d60
Mar 24 04:53:49 LudOS ludo[633]: github.com/libretro/ludo/libretro._Cfunc_bridge_retro_serialize(0x5a3a7084, 0x6225c078, 0x15cc, 0x0)
Mar 24 04:53:49 LudOS ludo[633]:         _cgo_gotypes.go:451 +0x38 fp=0x1432e00 sp=0x1432de8 pc=0x130558
Mar 24 04:53:49 LudOS ludo[633]: github.com/libretro/ludo/libretro.(*Core).Serialize.func1(0x5a3a7084, 0x6225c078, 0x15cc, 0x1d3164)
Mar 24 04:53:49 LudOS ludo[633]:         /home/travis/gopath/src/github.com/libretro/ludo/libretro/libretro.go:395 +0x7c fp=0x1432e18 sp=0x1432e00 pc=0x13316c
Mar 24 04:53:49 LudOS ludo[633]: github.com/libretro/ludo/libretro.(*Core).Serialize(0x148fb00, 0x15cc, 0x0, 0xf0, 0x0, 0xe0, 0x300)
Mar 24 04:53:49 LudOS ludo[633]:         /home/travis/gopath/src/github.com/libretro/ludo/libretro/libretro.go:395 +0x3c fp=0x1432e34 sp=0x1432e18 pc=0x131e5c
Mar 24 04:53:49 LudOS ludo[633]: github.com/libretro/ludo/savestates.Save(0x390c720, 0x21, 0x21, 0x21)
Mar 24 04:53:49 LudOS ludo[633]:         /home/travis/gopath/src/github.com/libretro/ludo/savestates/savestates.go:18 +0x30 fp=0x1432e7c sp=0x1432e34 pc=0x1d3174
Mar 24 04:53:49 LudOS ludo[633]: github.com/libretro/ludo/menu.buildSavestates.func1()
Mar 24 04:53:49 LudOS ludo[633]:         /home/travis/gopath/src/github.com/libretro/ludo/menu/scene_savestates.go:30 +0x68 fp=0x1432eb8 sp=0x1432e7c pc=0x2bd55c
Mar 24 04:53:49 LudOS ludo[633]: github.com/libretro/ludo/menu.genericInput(0x147d180, 0x3c8929cd)
Mar 24 04:53:49 LudOS ludo[633]:         /home/travis/gopath/src/github.com/libretro/ludo/menu/input.go:71 +0x320 fp=0x1432ec0 sp=0x1432eb8 pc=0x2b08bc
Mar 24 04:53:49 LudOS ludo[633]: github.com/libretro/ludo/menu.(*sceneSavestates).update(0x147d180, 0x3c8929cd)
Mar 24 04:53:49 LudOS ludo[633]:         /home/travis/gopath/src/github.com/libretro/ludo/menu/scene_savestates.go:85 +0x28 fp=0x1432ecc sp=0x1432ec0 pc=0x2b74e8
Mar 24 04:53:49 LudOS ludo[633]: github.com/libretro/ludo/menu.Update(0x3c8929cd)
Mar 24 04:53:49 LudOS ludo[633]:         /home/travis/gopath/src/github.com/libretro/ludo/menu/input.go:12 +0x44 fp=0x1432ed8 sp=0x1432ecc pc=0x2b0584
Mar 24 04:53:49 LudOS ludo[633]: main.runLoop(0x148e4e0)
Mar 24 04:53:49 LudOS ludo[633]:         /home/travis/gopath/src/github.com/libretro/ludo/main.go:47 +0x1a4 fp=0x1432f40 sp=0x1432ed8 pc=0x2bed7c
Mar 24 04:53:49 LudOS ludo[633]: main.main()
Mar 24 04:53:49 LudOS ludo[633]:         /home/travis/gopath/src/github.com/libretro/ludo/main.go:124 +0x408 fp=0x1432fc4 sp=0x1432f40 pc=0x2bf1c4
Mar 24 04:53:49 LudOS ludo[633]: runtime.main()
Mar 24 04:53:49 LudOS ludo[633]:         /home/travis/.gimme/versions/go1.11.linux.amd64/src/runtime/proc.go:201 +0x204 fp=0x1432fe4 sp=0x1432fc4 pc=0x5b12c
Mar 24 04:53:49 LudOS ludo[633]: runtime.goexit()
Mar 24 04:53:49 LudOS ludo[633]:         /home/travis/.gimme/versions/go1.11.linux.amd64/src/runtime/asm_arm.s:867 +0x4 fp=0x1432fe4 sp=0x1432fe4 pc=0x8438c
Mar 24 04:53:49 LudOS ludo[633]: goroutine 8 [chan receive]:
Mar 24 04:53:49 LudOS ludo[633]: github.com/libretro/ludo/core.Init.func1(0x35136e0)
Mar 24 04:53:49 LudOS ludo[633]:         /home/travis/gopath/src/github.com/libretro/ludo/core/core.go:45 +0x40
Mar 24 04:53:49 LudOS ludo[633]: created by github.com/libretro/ludo/core.Init
Mar 24 04:53:49 LudOS ludo[633]:         /home/travis/gopath/src/github.com/libretro/ludo/core/core.go:44 +0x7c
Mar 24 04:53:49 LudOS systemd[1]: ludo.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Mar 24 04:53:49 LudOS systemd[1]: ludo.service: Failed with result 'exit-code'.
johnnyq commented 5 years ago

This happens to me when I try to Save State on NES or Gameboy the OSD comes up and says retro_serialize failed.

johnnyq commented 4 years ago

This seems to happen when I play snes and sega then switch over to nes and savestate I get the retro_serialize failed. If I reboot and just play nes its fine

johnnyq commented 4 years ago

I'm still getting this error even with the latest version of ludo on both my Pi3 and Pi4. Any idea what may be causing this? I was thinking maybe a memory leak i'm just not sure

kivutar commented 4 years ago

No idea for now

johnnyq commented 4 years ago

Okay I have more info

Hardware Tested: Raspberry pi 3b+ and Pi4 on LudOS Latest version, also on a PC with Ubuntu 20.04 and LUDO 0.12.0 with Gameboy, NES, SNES and Sega

Steps to Reproduce

I was able to reproduce the issue all the time.

Now heres the weird thing

It seems if you load up any nes game upon boot then play any other system and go back to nes and save state it works

This is weird and dont understand it, but maybe this will give a clue on whats going on.

johnnyq commented 4 years ago

Also it appears Game Boy is Affected as well load up any nes, snes sega then load up a gameboy game and choose to save you will get a retro_serialize failed.

johnnyq commented 4 years ago

Another Interesting bit, If you load up gameboy game then load up an NES game then try to save it also give Retro_Serialize failed.

johnnyq commented 4 years ago

The Bug appears to be with the NES and Gameboy Emulator

kivutar commented 3 years ago

This should be fixed with my last change.

kivutar commented 3 years ago

Reopen if it's still happening

johnnyq commented 3 years ago

Hi @kivutar I have noticed this is still happening. Seems to happen with the Gameboy Emulator and NES Emulator

The easiest way to replicate on initial boot:

You will get the retro_serialization failed and no save will be saved

This must be done on initial boot

however if you run

NES core first the problem doesnt happen you can switch to another core and then back to NES and save states will work

Its a really odd issue

kivutar commented 3 years ago

Same here, it doesn't happen on OSX for me. Something is wrong, but the steps to reproduce won't always work.

johnnyq commented 2 years ago

This is fixed! =] Thanks @kivutar Im not sure what commit fixed it but its working like a charm

johnnyq commented 2 years ago

I think commit 6c2a6cf89ade4bc87a303d526653c3a4cb88322b fixed the issue

kivutar commented 2 years ago

OK cool :D