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.36k stars 2.18k forks source link

delayed segfault on loading savestate in fl0w #4512

Closed i30817 closed 10 years ago

i30817 commented 11 years ago

wait 10 seconds or so, for the 'transformation' to end.

https://drive.google.com/file/d/0BzxkBmaf1EiWcDR4MGkyWXppSjg/edit?usp=sharing

unknownbrackets commented 10 years ago

It seems like this is related to ATRAC3+ decoding. It doesn't crash at all without the savestate?

-[Unknown]

i30817 commented 10 years ago

Not that i could tell. It was just pure luck (ok lots of savescumming) that i saved before the crash.

i30817 commented 10 years ago

Uploaded the save to my google drive since i was worried about mediafire deleting it https://drive.google.com/file/d/0BzxkBmaf1EiWcDR4MGkyWXppSjg/edit?usp=sharing

unknownbrackets commented 10 years ago

Does this still happen since the ffmpeg update?

-[Unknown]

i30817 commented 10 years ago

Yes. I debugged it and got this out: Program received signal SIGSEGV, Segmentation fault. 0x0000000000ac2341 in ff_atrac3p_generate_tones (ch_unit=, fdsp=0x23b03e0, ch_num=, sb=, out=) at libavcodec/atrac3plusdsp.c:199 199 libavcodec/atrac3plusdsp.c: No such file or directory. (gdb)

(complete backtrace is useless btw, lots of #1 0x8000000080ac1c18 in ?? () lines, i don't know why) I suppose i should build a debug version of the included ffmpeg too? Apparently it isn't built by cmake but distributed already built?

edit: from this code apparently, if i found the right file: ffmpeg/libavcodec/atrac3plusdsp.c

if (tones_now->pend_env.has_stop_point &&
    tones_now->pend_env.stop_pos >= tones_next->curr_env.start_pos) {
i30817 commented 10 years ago

If you could reduce this to a test case and punt it to Max it would probably be fixed. If that is, it isn't the fault of the save state saving or something.

unknownbrackets commented 10 years ago

Oh, you probably need to rebuild ffmpeg. I don't think the distributed one was updated yet.

Just go in there are run ./linux_x86-64.sh (or ./linux_x86.sh as the case may be.)

-[Unknown]

i30817 commented 10 years ago

It gives a few deprecation warnings and a full blown undefined reference later: edit: user error, see next post edit2: it wasn't :( /home/i30817/Documents/Netbeans_projects/ppsspp/ffmpeg/linux/x86_64/lib/libavcodec.a(mpegvideo_enc.o): In function ff_dct_encode_init': /home/i30817/Documents/Netbeans_projects/ppsspp/ffmpeg/libavcodec/mpegvideo_enc.c:229: undefined reference toff_h263dsp_init' /home/i30817/Documents/Netbeans_projects/ppsspp/ffmpeg/linux/x86_64/lib/libavcodec.a(h263dec.o): In function ff_h263_decode_init': /home/i30817/Documents/Netbeans_projects/ppsspp/ffmpeg/libavcodec/h263dec.c:127: undefined reference toff_h263dsp_init' collect2: error: ld returned 1 exit status make[2]: * [PPSSPPSDL] Error 1 make[1]: * [CMakeFiles/PPSSPPSDL.dir/all] Error 2 make: *\ [all] Error 2

adding #include "h263dsp.h", which contains the definition, on those files but it did nothing useful for some reason, maybe it's wrong. Error only occurs when linking PPSSPPSDL, not before, when building ffmpeg with the linux_x86-64.sh... but those files are all libavcodec.a ones.

unknownbrackets commented 10 years ago

Try removing the mjpeg encoder: https://github.com/hrydgard/ppsspp-ffmpeg/commit/5037e3627327907d989f83fa595041a84e9f2f9e#commitcomment-5177869

-[Unknown]

i30817 commented 10 years ago

I actually suspect something like this: http://cmake.3232098.n2.nabble.com/static-library-linking-problem-td7584444.html

It would make sense if it tried to access those functions as if it was C++ and they're actually mangled as C. So building in the sh file gives no prob, and trying to verify the functions in the C++ linker of static files blows up although they're all inside the same .a file.

To be clear, what you're suggest there is revert that commit or what?

unknownbrackets commented 10 years ago

Well, it could also be that our flags are wrong and we're not ending up with the h263 funcs we need in the library, which we would only get an error about at link time.

-[Unknown]

i30817 commented 10 years ago

Well i sincerely don't feel like i'm able to resolve this myself. How would i go about disabling mjpeg like you said?

edit: in the sh file, i see

i30817 commented 10 years ago

Well removing --enable-encoder=mjpeg didn't fully resolve it but one of the errors went away. This still remains: /home/i30817/Documents/Netbeans_projects/ppsspp/ffmpeg/linux/x86_64/lib/libavcodec.a(h263dec.o): In function ff_h263_decode_init': /home/i30817/Documents/Netbeans_projects/ppsspp/ffmpeg/libavcodec/h263dec.c:127: undefined reference toff_h263dsp_init' collect2: error: ld returned 1 exit status

trying to removing ffv1 for good measure now. edit: nope

i30817 commented 10 years ago

http://www.ffmpeg.org/faq.html#I_0027m-using-FFmpeg-from-within-my-C-application-but-the-linker-complains-about-missing-symbols-from-the-libraries-themselves_002e

either 4.8 or 4.9

which parts of PPSSPP use ffmpeg includes?

i30817 commented 10 years ago

Never mind, i found them with a grep. I'm going to try to put in the extern "C" thing around those and rebuild to see what's what.

edit: they're all already extern "C". All i found with this grep at least: grep -R --exclude-dir=ffmpeg* "#include" . | grep 'libavcodec/|libavformat/|libswresample/|libswscale/|libavutil'

unknownbrackets commented 10 years ago

Well, the undefined reference is from within ffmpeg, so that means it's nothing to do with PPSSPP or C++, most likely.

It could be link order, I suppose, but it worked before, right?

It seems likely to me that something isn't getting compiled and put into the library, but I don't know what/why.

You could try removing "--disable-all" from the sh. ffmpeg will be bigger but maybe it will work.

-[Unknown]

i30817 commented 10 years ago

Removing the --disable-everything appears to have worked for building. And the bug is fixed. That is, there is a conspicuous lack of sound when it would crash before, but it's not crashing anymore and the game recovers the sound just a second later anyway. In neither debug or normal builds.

Closed!

unknownbrackets commented 10 years ago

Hmm, well, there's something wrong there but tbh I'm pretty sure we have other bugs that cover the general issue. Glad it works now.

We need to figure out that ffmpeg mess...

-[Unknown]

i30817 commented 10 years ago

btw @unknownbrackets if youre curious, this is what a log enabled run of that savestate shows in the console (without the crash now) before and during the pause: 01:44:243 idle0 I[COMMON]: Common/ChunkFile.cpp:165 ChunkReader: Loading /home/i30817/.config/ppsspp/PSP/PPSSPP_STATE/NPUG80086_1.00_2.ppst 01:44:524 idle0 I[SCEGE]: GLES/Framebuffer.cpp:1632 Destroying FBO for 00088000 : 480 x 272 x 3 01:44:524 idle0 I[SCEGE]: GLES/Framebuffer.cpp:1632 Destroying FBO for 10198010 : 256 x 128 x 3 01:44:524 idle0 I[SCEGE]: GLES/Framebuffer.cpp:1632 Destroying FBO for 201b8020 : 128 x 64 x 3 01:44:524 idle0 I[SCEGE]: GLES/Framebuffer.cpp:1632 Destroying FBO for 301c0030 : 128 x 64 x 3 01:44:524 idle0 I[SCEGE]: GLES/Framebuffer.cpp:1632 Destroying FBO for 00000000 : 480 x 272 x 3 01:44:526 idle0 I[COMMON]: Common/ChunkFile.h:607 ChunkReader: Done loading /home/i30817/.config/ppsspp/PSP/PPSSPP_STATE/NPUG80086_1.00_2.ppst 01:44:548 swap thread I[SCEGE]: GLES/Framebuffer.cpp:794 Creating FBO for 00088000 : 480 x 272 x 3 01:44:548 swap thread I[SCEGE]: GLES/Framebuffer.cpp:794 Creating FBO for 10198010 : 256 x 128 x 3 01:44:548 swap thread W[SCEGE]: GLES/Framebuffer.cpp:814 FBO reusing depthbuffer, 10198010/00110000 and 00088000/00110000 01:44:548 swap thread I[SCEGE]: GLES/Framebuffer.cpp:794 Creating FBO for 201b8020 : 128 x 64 x 3 01:44:548 swap thread W[SCEGE]: GLES/Framebuffer.cpp:814 FBO reusing depthbuffer, 201b8020/00110000 and 00088000/00110000 01:44:549 swap thread I[SCEGE]: GLES/Framebuffer.cpp:794 Creating FBO for 301c0030 : 128 x 64 x 3 01:44:549 swap thread W[SCEGE]: GLES/Framebuffer.cpp:814 FBO reusing depthbuffer, 301c0030/00110000 and 00088000/00110000 01:44:694 swap thread I[SCEGE]: GLES/Framebuffer.cpp:794 Creating FBO for 00000000 : 480 x 272 x 3 01:45:494 stream threa I[ME]: HLE/sceAtrac.cpp:973 sceAtracReleaseAtracID(1) 01:53:105 stream threa I[ME]: HW/MediaEngine.cpp:84 FF: Invalid gain location: ch=0, sb=1, pos=2, val=32 01:53:105 stream threa E[ME]: HLE/sceAtrac.cpp:608 avcodec_decode_audio4: Error decoding audio -1094995529 01:53:105 stream threa E[ME]: HLE/sceAtrac.cpp:818 UNIMPL sceAtracGetInternalErrorInfo(0, 09fdc254) 01:53:105 stream threa I[ME]: HLE/sceAtrac.cpp:973 sceAtracReleaseAtracID(0) 01:53:242 stream threa I[ME]: HLE/sceAtrac.cpp:1272 0=sceAtracSetDataAndGetID(089d5340, 00020000) 01:53:242 stream threa W[ME]: HLE/sceAtrac.cpp:1162 This is an atrac3+ stereo audio

i30817 commented 10 years ago

i've noticed the sound crackles too. But i guess that is another bug.