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.43k stars 2.19k forks source link

[GNU/Linux] [Ridge Racer] PPSSPP core hangs when audio is about to start playing #19346

Open vanfanel opened 4 months ago

vanfanel commented 4 months ago

Game or games this happens in

ULUS-10001- Ridge Racer

What area of the game / PPSSPP

When the game starts, it stalls forever on the Rally-X loading minigame when it's about to start playing music and effects.

It doesn't happen on the latest stable version, only on the GIT code version.

Started happening with that commit: https://github.com/hrydgard/ppsspp/commit/a1ac79c18354074d090824f44da612a74cdc7266

Both Libretro core and standalone seem to be affected.

What should happen

The game should proceed normally, as it does on the stable version of the code.

Logs

log.txt

Platform

libretro / Retroarch

Mobile device model or graphics card (GPU)

Intel XE graphics

PPSSPP version affected

Latest GIT code

Last working version

Latest stable

Graphics backend (3D API)

Vulkan

Checklist

hrydgard commented 4 months ago

That is .. not expected. Certainly doesn't happen in standalone.

Could you try some intermediate builds to try to narrow it down? Do other games work?

vanfanel commented 4 months ago

@hrydgard I tried with several builds from some days ago, and they all do the same.

Other games like Lumines seem to work well.

hrydgard commented 4 months ago

Well, try some ones a bit further back, so we can try to identify what change caused it.

anr2me commented 4 months ago

@hrydgard I tried with several builds from some days ago, and they all do the same.

Other games like Lumines seem to work well.

you may want to test commits/PR related to audio, like related to ffmpeg/atrac3 for example, most likely atrac3-related.

vanfanel commented 4 months ago

Well, I put some good time into this, and found out this is the commit where the bug started:

https://github.com/hrydgard/ppsspp/commit/a1ac79c18354074d090824f44da612a74cdc7266

Note the game may still run normally sometimes: it hangs as described most of the times, but 1 of each 5 times it runs apparently well.

vanfanel commented 4 months ago

To my surprise, standalone has exactly the same bug. I have updated the bug description accordingly.

hrydgard commented 4 months ago

Really? for me, it works perfectly. Well, I only tried four times in a row...

Still, that's important information, and thanks for tracking down when it started for you. Hope I can figure out a way to repro the problem.

vanfanel commented 4 months ago

I have found out what causes the bug on my system. I usually do my builds with

-DCMAKE_C_FLAGS="-march=native -mtune=native"
-DCMAKE_CXX_FLAGS="-march=native -mtune=native"

Not passing that, the game won't hang at that point.

I should add that I'm using Debian 12, with GCC 12.2.0:

~/src/libretro/ppsspp/b5$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/12/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 12.2.0-14' --with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-12 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-12-bTRWOB/gcc-12-12.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-12-bTRWOB/gcc-12-12.2.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (Debian 12.2.0-14)

This is an i5-1235U (Intel 12th gen) based system, and this is what -march=native does here:

~/src/libretro/ppsspp/b5$ gcc -march=native -Q --help=target
The following options are target specific:
  -m128bit-long-double                  [enabled]
  -m16                                  [disabled]
  -m32                                  [disabled]
  -m3dnow                               [disabled]
  -m3dnowa                              [disabled]
  -m64                                  [enabled]
  -m80387                               [enabled]
  -m8bit-idiv                           [disabled]
  -m96bit-long-double                   [disabled]
  -mabi=                                sysv
  -mabm                                 [enabled]
  -maccumulate-outgoing-args            [disabled]
  -maddress-mode=                       long
  -madx                                 [enabled]
  -maes                                 [enabled]
  -malign-data=                         compat
  -malign-double                        [disabled]
  -malign-functions=                    0
  -malign-jumps=                        0
  -malign-loops=                        0
  -malign-stringops                     [enabled]
  -mamx-bf16                            [disabled]
  -mamx-int8                            [disabled]
  -mamx-tile                            [disabled]
  -mandroid                             [disabled]
  -march=                               alderlake
  -masm=                                att
  -mavx                                 [enabled]
  -mavx2                                [enabled]
  -mavx256-split-unaligned-load         [disabled]
  -mavx256-split-unaligned-store        [disabled]
  -mavx5124fmaps                        [disabled]
  -mavx5124vnniw                        [disabled]
  -mavx512bf16                          [disabled]
  -mavx512bitalg                        [disabled]
  -mavx512bw                            [disabled]
  -mavx512cd                            [disabled]
  -mavx512dq                            [disabled]
  -mavx512er                            [disabled]
  -mavx512f                             [disabled]
  -mavx512fp16                          [disabled]
  -mavx512ifma                          [disabled]
  -mavx512pf                            [disabled]
  -mavx512vbmi                          [disabled]
  -mavx512vbmi2                         [disabled]
  -mavx512vl                            [disabled]
  -mavx512vnni                          [disabled]
  -mavx512vp2intersect                  [disabled]
  -mavx512vpopcntdq                     [disabled]
  -mavxvnni                             [enabled]
  -mbionic                              [disabled]
  -mbmi                                 [enabled]
  -mbmi2                                [enabled]
  -mbranch-cost=<0,5>                   3
  -mcall-ms2sysv-xlogues                [disabled]
  -mcet-switch                          [disabled]
  -mcld                                 [disabled]
  -mcldemote                            [disabled]
  -mclflushopt                          [enabled]
  -mclwb                                [enabled]
  -mclzero                              [disabled]
  -mcmodel=                             [default]
  -mcpu=                      
  -mcrc32                               [enabled]
  -mcx16                                [enabled]
  -mdirect-extern-access                [enabled]
  -mdispatch-scheduler                  [disabled]
  -mdump-tune-features                  [disabled]
  -menqcmd                              [disabled]
  -mf16c                                [enabled]
  -mfancy-math-387                      [enabled]
  -mfentry                              [disabled]
  -mfentry-name=              
  -mfentry-section=           
  -mfma                                 [enabled]
  -mfma4                                [disabled]
  -mforce-drap                          [disabled]
  -mforce-indirect-call                 [disabled]
  -mfp-ret-in-387                       [enabled]
  -mfpmath=                             sse
  -mfsgsbase                            [enabled]
  -mfunction-return=                    keep
  -mfused-madd                          -ffp-contract=fast
  -mfxsr                                [enabled]
  -mgeneral-regs-only                   [disabled]
  -mgfni                                [enabled]
  -mglibc                               [enabled]
  -mhard-float                          [enabled]
  -mharden-sls=                         none
  -mhle                                 [disabled]
  -mhreset                              [enabled]
  -miamcu                               [disabled]
  -mieee-fp                             [enabled]
  -mincoming-stack-boundary=            0
  -mindirect-branch-cs-prefix           [disabled]
  -mindirect-branch-register            [disabled]
  -mindirect-branch=                    keep
  -minline-all-stringops                [disabled]
  -minline-stringops-dynamically        [disabled]
  -minstrument-return=                  none
  -mintel-syntax                        -masm=intel
  -mkl                                  [disabled]
  -mlarge-data-threshold=<number>       65536
  -mlong-double-128                     [disabled]
  -mlong-double-64                      [disabled]
  -mlong-double-80                      [enabled]
  -mlwp                                 [disabled]
  -mlzcnt                               [enabled]
  -mmanual-endbr                        [disabled]
  -mmemcpy-strategy=          
  -mmemset-strategy=          
  -mmitigate-rop                        [disabled]
  -mmmx                                 [enabled]
  -mmovbe                               [enabled]
  -mmovdir64b                           [enabled]
  -mmovdiri                             [enabled]
  -mmove-max=                           128
  -mmpx                                 [disabled]
  -mms-bitfields                        [disabled]
  -mmusl                                [disabled]
  -mmwait                               [enabled]
  -mmwaitx                              [disabled]
  -mneeded                              [disabled]
  -mno-align-stringops                  [disabled]
  -mno-default                          [disabled]
  -mno-fancy-math-387                   [disabled]
  -mno-push-args                        [disabled]
  -mno-red-zone                         [disabled]
  -mno-sse4                             [disabled]
  -mnop-mcount                          [disabled]
  -momit-leaf-frame-pointer             [disabled]
  -mpc32                                [disabled]
  -mpc64                                [disabled]
  -mpc80                                [disabled]
  -mpclmul                              [enabled]
  -mpcommit                             [disabled]
  -mpconfig                             [disabled]
  -mpku                                 [enabled]
  -mpopcnt                              [enabled]
  -mprefer-avx128                       -mprefer-vector-width=128
  -mprefer-vector-width=                none
  -mpreferred-stack-boundary=           0
  -mprefetchwt1                         [disabled]
  -mprfchw                              [enabled]
  -mptwrite                             [enabled]
  -mpush-args                           [enabled]
  -mrdpid                               [enabled]
  -mrdrnd                               [enabled]
  -mrdseed                              [enabled]
  -mrecip                               [disabled]
  -mrecip=                    
  -mrecord-mcount                       [disabled]
  -mrecord-return                       [disabled]
  -mred-zone                            [enabled]
  -mregparm=                            6
  -mrelax-cmpxchg-loop                  [disabled]
  -mrtd                                 [disabled]
  -mrtm                                 [disabled]
  -msahf                                [enabled]
  -mserialize                           [enabled]
  -msgx                                 [disabled]
  -msha                                 [enabled]
  -mshstk                               [enabled]
  -mskip-rax-setup                      [disabled]
  -msoft-float                          [disabled]
  -msse                                 [enabled]
  -msse2                                [enabled]
  -msse2avx                             [disabled]
  -msse3                                [enabled]
  -msse4                                [enabled]
  -msse4.1                              [enabled]
  -msse4.2                              [enabled]
  -msse4a                               [disabled]
  -msse5                                -mavx
  -msseregparm                          [disabled]
  -mssse3                               [enabled]
  -mstack-arg-probe                     [disabled]
  -mstack-protector-guard-offset= 
  -mstack-protector-guard-reg= 
  -mstack-protector-guard-symbol= 
  -mstack-protector-guard=              tls
  -mstackrealign                        [disabled]
  -mstore-max=                          128
  -mstringop-strategy=                  [default]
  -mstv                                 [enabled]
  -mtbm                                 [disabled]
  -mtls-dialect=                        gnu
  -mtls-direct-seg-refs                 [enabled]
  -mtsxldtrk                            [disabled]
  -mtune-ctrl=                
  -mtune=                               alderlake
  -muclibc                              [disabled]
  -muintr                               [disabled]
  -mvaes                                [enabled]
  -mveclibabi=                          [default]
  -mvect8-ret-in-mem                    [disabled]
  -mvpclmulqdq                          [enabled]
  -mvzeroupper                          [enabled]
  -mwaitpkg                             [enabled]
  -mwbnoinvd                            [disabled]
  -mwidekl                              [disabled]
  -mx32                                 [disabled]
  -mxop                                 [disabled]
  -mxsave                               [enabled]
  -mxsavec                              [enabled]
  -mxsaveopt                            [enabled]
  -mxsaves                              [enabled]

  Known assembler dialects (for use with the -masm= option):
    att intel

  Known ABIs (for use with the -mabi= option):
    ms sysv

  Known code models (for use with the -mcmodel= option):
    32 kernel large medium small

  Valid arguments to -mfpmath=:
    387 387+sse 387,sse both sse sse+387 sse,387

  Known choices for mitigation against straight line speculation with -mharden-sls=:
    all indirect-jmp none return

  Known indirect branch choices (for use with the -mindirect-branch=/-mfunction-return= options):
    keep thunk thunk-extern thunk-inline

  Known choices for return instrumentation with -minstrument-return=:
    call none nop5

  Known data alignment choices (for use with the -malign-data= option):
    abi cacheline compat

  Known vectorization library ABIs (for use with the -mveclibabi= option):
    acml svml

  Known address mode (for use with the -maddress-mode= option):
    long short

  Known preferred register vector length (to use with the -mprefer-vector-width= option):
    128 256 512 none

  Known stack protector guard (for use with the -mstack-protector-guard= option):
    global tls

  Valid arguments to -mstringop-strategy=:
    byte_loop libcall loop rep_4byte rep_8byte rep_byte unrolled_loop vector_loop

  Known TLS dialects (for use with the -mtls-dialect= option):
    gnu gnu2

  Known valid arguments for -march= option:
    i386 i486 i586 pentium lakemont pentium-mmx winchip-c6 winchip2 c3 samuel-2 c3-2 nehemiah c7 esther i686 pentiumpro pentium2 pentium3 pentium3m pentium-m pentium4 pentium4m prescott nocona core2 nehalem corei7 westmere sandybridge corei7-avx ivybridge core-avx-i haswell core-avx2 broadwell skylake skylake-avx512 cannonlake icelake-client rocketlake icelake-server cascadelake tigerlake cooperlake sapphirerapids alderlake bonnell atom silvermont slm goldmont goldmont-plus tremont knl knm intel geode k6 k6-2 k6-3 athlon athlon-tbird athlon-4 athlon-xp athlon-mp x86-64 x86-64-v2 x86-64-v3 x86-64-v4 eden-x2 nano nano-1000 nano-2000 nano-3000 nano-x2 eden-x4 nano-x4 k8 k8-sse3 opteron opteron-sse3 athlon64 athlon64-sse3 athlon-fx amdfam10 barcelona bdver1 bdver2 bdver3 bdver4 znver1 znver2 znver3 btver1 btver2 generic native

  Known valid arguments for -mtune= option:
    generic i386 i486 pentium lakemont pentiumpro pentium4 nocona core2 nehalem sandybridge haswell bonnell silvermont goldmont goldmont-plus tremont knl knm skylake skylake-avx512 cannonlake icelake-client icelake-server cascadelake tigerlake cooperlake sapphirerapids alderlake rocketlake intel geode k6 athlon k8 amdfam10 bdver1 bdver2 bdver3 bdver4 btver1 btver2 znver1 znver2 znver3
vanfanel commented 4 months ago

Passing -march=alderlake instead, which is a "safe" flag, yields the same results: the game hangs at the exact same point.

anr2me commented 4 months ago

so this is actually cpu optimization issue? and have nothing to do with ffmpeg/atrac3?

hrydgard commented 4 months ago

It sounds like either a compiler bug, or we are accidentally relying on undefined behavior somewhere, which is not good if so. Not really sure how best to find it... But presumably it'll be something in a1ac79c . .

vanfanel commented 4 months ago

@hrydgard I did a debug standalone build, and ran it with GDB so I can point you guys to the point where it fails:

log.txt

Hope it helps.

hrydgard commented 4 months ago

Thanks for the backtrace, that might help figuring it out.

However, this is inconsistent with your initial report, you said that it hangs, but that's clearly a crash?

vanfanel commented 4 months ago

Thanks for the backtrace, that might help figuring it out.

However, this is inconsistent with your initial report, you said that it hangs, but that's clearly a crash?

It's an idiomatic mistake on my side probably: the game just "hangs there" (still image on the screen) and I can see on the underlying terminal that it crashed. It's both things.

hrydgard commented 4 months ago

Ah, alright. From my perspective a hang is when it goes into an infinite loop or a deadlock.

hrydgard commented 4 months ago

I've been running a bit with both valgrind and UBSAN and it finds nothing. I can't reproduce this on my systems at all :/

vanfanel commented 4 months ago

I've been running a bit with both valgrind and UBSAN and it finds nothing. I can't reproduce this on my systems at all :/

What GCC version are you using? Also, this issue affects standalone too, so the libretro tag isn't entirely adequate I think?

hrydgard commented 4 months ago

Just did a release build, added -march alderlake to both C and CPP flags, and this doesn't happen.

hrydgard@THREADRIPPER:~/ppsspp$ gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

Seems I'm on an older GCC though.

Can you post your full command line you use to build the standalone version?

vanfanel commented 4 months ago

@hrydgard Of course. This is how I build it (I use Wayland only, no X11 deps on my system):

cmake .. -DCMAKE_BUILD_TYPE=Release -DUSE_WAYLAND_WSI=ON -DUSE_VULKAN_DISPLAY_KHR=OFF -DUSING_X11_VULKAN=OFF -DUSING_GLES2=ON -DUSE_DISCORD=OFF \
-DCMAKE_C_FLAGS="-DEGL_NO_X11 -march=native -mtune=native" \
-DCMAKE_CXX_FLAGS="-DEGL_NO_X11 -march=native -mtune=native"

Between GCC 11 and GCC 12.x, there was a lot of Alderlake specific stuff added. In other words, in GCC 11 the Alderlake march was supported, but wasn't doing much as far as I know.

So I am inclined to think that GCC version matters here. Which is a PITA for tests on your side :(

hrydgard commented 4 months ago

Well, not that much of a PITA. I'll just install Ubuntu 24 in a second WSL VM.

(I do have a laptop that actually runs linux bare-metal, but I won't upgrade that right now if I can avoid it)

hrydgard commented 4 months ago

Though, seems I'm ending up with gcc 13, heh.

hrydgard commented 4 months ago

Built with your commandline exactly, on GCC 13. Ridge Racer works perfectly, no hang.

I'll try with =alderlake too. (nope)

hrydgard commented 4 months ago

Also, can you try -fno-strict-aliasing ? Although the code that seems responsible in this case doesn't seem to make use of aliasing tricks.

vanfanel commented 4 months ago

@hrydgard I upgraded to gcc 13.3.0 (latest stable gcc version available) on my Debian 12 system, and after rebuilding PPSSPP with it, the same problem is present on both the Libretro and standalone versions.

Also tried passing -fno-strict-aliasing, but that made no difference as you foresaw.

I don't know what else to try.

vanfanel commented 4 months ago

@hrydgard Just in case, here's a debug session of the GCC 13.3.0 build:

Thread 1 "retroarch" received signal SIGSEGV, Segmentation fault.
0x00007ffff5f9c2d6 in ff_atrac3p_ipqf (dct_ctx=dct_ctx@entry=0x55555a673280, hist=hist@entry=0x55555a6776d0, 
    in=in@entry=0x55555a66b180, out=out@entry=0x55555a66f180) at /root/src/libretro/ppsspp/ext/at3_standalone/atrac3plusdsp.cpp:649
649                 hist->buf2[hist_pos][i] = idct_out[7 - i];
(gdb) p hist
$1 = (Atrac3pIPQFChannelCtx *) 0x55555a6776d0
(gdb) p hist->buf2
$2 = {{0, 0, 0, 0, 0, 0, 0, 0} <repeats 24 times>}
(gdb) p hist->buf2[hist_pos][i]
value has been optimized out
(gdb) p idct_out[7 - i]
value has been optimized out
(gdb) bt
#0  0x00007ffff5f9c2d6 in ff_atrac3p_ipqf (dct_ctx=dct_ctx@entry=0x55555a673280, hist=hist@entry=0x55555a6776d0, 
    in=in@entry=0x55555a66b180, out=out@entry=0x55555a66f180) at /root/src/libretro/ppsspp/ext/at3_standalone/atrac3plusdsp.cpp:649
#1  0x00007ffff5f9af53 in reconstruct_frame (num_channels=<optimized out>, ch_unit=0x55555a6732f0, ctx=<optimized out>)
    at /root/src/libretro/ppsspp/ext/at3_standalone/atrac3plusdec.cpp:291
#2  atrac3p_decode_frame (ctx=0x55555a663160, out_data=0x55555a622540, nb_samples=0x7fffffffdcfc, indata=<optimized out>, 
    indata_size=376) at /root/src/libretro/ppsspp/ext/at3_standalone/atrac3plusdec.cpp:346
#3  0x00007ffff5c8eb87 in Atrac3Audio::Decode (this=this@entry=0x55555a622510, inbuf=<optimized out>, inbytes=inbytes@entry=376, 
    inbytesConsumed=inbytesConsumed@entry=0x0, outputChannels=outputChannels@entry=2, outbuf=outbuf@entry=0x0, outSamples=0x0)
    at /root/src/libretro/ppsspp/Core/HW/Atrac3Standalone.cpp:82
#4  0x00007ffff5dbfb03 in Atrac::SeekToSample (this=this@entry=0x555557bcc2e0, sample=0)
    at /root/src/libretro/ppsspp/Core/HLE/AtracCtx.cpp:859
#5  0x00007ffff5dbfc9d in Atrac::DecodeData (this=this@entry=0x555557bcc2e0, outbuf=0x7ffe09273fc0 "", 
    outbufPtr=outbufPtr@entry=153567168, SamplesNum=SamplesNum@entry=0x7fffffffdeb4, finish=finish@entry=0x7fffffffdeb8, 
    remains=remains@entry=0x7fffffffdebc) at /root/src/libretro/ppsspp/Core/HLE/AtracCtx.cpp:955
#6  0x00007ffff5bfc18f in sceAtracDecodeData (remainAddr=167706208, finishFlagAddr=167706216, numSamplesAddr=167706212, 
    outAddr=153567168, atracID=<optimized out>) at /root/src/libretro/ppsspp/Core/HLE/sceAtrac.cpp:261
#7  WrapU_IUUUU<sceAtracDecodeData> () at /root/src/libretro/ppsspp/Core/HLE/FunctionWrappers.h:588
#8  0x00007ffff5befa5b in CallSyscallWithoutFlags (info=0x7ffff6857990 <sceAtrac3plus+48>)
    at /root/src/libretro/ppsspp/Core/HLE/HLE.cpp:659

You can see where it segfaults exactly. The exact line inside the atrac3 playback code, which is this one:

https://github.com/hrydgard/ppsspp/blob/cc5763cffdb60488785e41bf2460e3df09d27a45/ext/at3_standalone/atrac3plusdsp.cpp#L649

Just in case it gives some information... I am not into compiler technology and the line seems harmless to me, but well, there's where it segfaults consistently with the Alder Lake optimizations activated.

hrydgard commented 4 months ago

Weird that I can't repro it then :(

That's a RelDebug build I guess, not a Debug build? I only tried Release build

vanfanel commented 4 months ago

It's a debug build because I passed -O0 -ggdb but also the native flags.

vanfanel commented 4 months ago

Well, I went as far as to upgrade my own native system to Debian Testing, and the problem is still happening with the "native" flags on the exact same spot.

So I guess someone will find it in the future and the information on this thread will be useful. For now, nothing else comes to my mind but building without these flags.

hrydgard commented 4 months ago

If you passed -O0, you shouldn't get "value has been optimized out" in the output, right?

anr2me commented 4 months ago

It's strange to shows "value has been optimized" with -O0 Alternatively, try temporary adding this #pragma optimize("", off) line at the top of atrac3plusdec.cpp file to prevent that file from being optimized.

vanfanel commented 4 months ago

@hrydgard I was doing:

cmake .. -DLIBRETRO=ON -DUSE_VULKAN_DISPLAY_KHR=ON -DUSE_WAYLAND_WSI=OFF -DUSING_X11_VULKAN=OFF \
-DCMAKE_BUILD_TYPE=Release -DUSING_GLES2=ON -DUSE_DISCORD=OFF \
-DCMAKE_C_FLAGS=" -march=native -mtune=native -O0 -ggdb" \
-DCMAKE_CXX_FLAGS="-march=native -mtune=native -O0 -ggdb"

...which is wrong because I was mixing -DCMAKE_BUILD_TYPE=Release with -O0 -ggdb. That's why you saw these values optimized out.

Now, if I do:

cmake .. -DLIBRETRO=ON -DUSE_VULKAN_DISPLAY_KHR=ON -DUSE_WAYLAND_WSI=OFF -DUSING_X11_VULKAN=OFF -DCMAKE_BUILD_TYPE=Debug -DUSING_GLES2=ON -DUSE_DISCORD=OFF -DCMAKE_C_FLAGS="-march=native -mtune=native -O0 -ggdb" -DCMAKE_CXX_FLAGS="-march=native -mtune=native -O0 -ggdb"

...then there are no segfaults at all, so I can't debug these values.

@anr2me If I add #pragma optimize("", off) line at the top of atrac3plusdsp.cpp and do an optimized build like this:

cmake .. -DLIBRETRO=ON -DUSE_VULKAN_DISPLAY_KHR=ON -DUSE_WAYLAND_WSI=OFF -DUSING_X11_VULKAN=OFF \
-DCMAKE_BUILD_TYPE=Release -DUSING_GLES2=ON -DUSE_DISCORD=OFF \
-DCMAKE_C_FLAGS=" -march=native -mtune=native" \
-DCMAKE_CXX_FLAGS=" -march=native -mtune=native"

...then it still segfaults:


Thread 1 "retroarch" received signal SIGSEGV, Segmentation fault.
0x00007ffff5f7a496 in ff_atrac3p_ipqf(FFTContext*, Atrac3pIPQFChannelCtx*, float const*, float*) ()
   from /root/.config/retroarch/cores/ppsspp_libretro.so
(gdb) bt
#0  0x00007ffff5f7a496 in ff_atrac3p_ipqf(FFTContext*, Atrac3pIPQFChannelCtx*, float const*, float*) ()
   from /root/.config/retroarch/cores/ppsspp_libretro.so
#1  0x00007ffff5f79113 in atrac3p_decode_frame(ATRAC3PContext*, float**, int*, unsigned char const*, int) ()
   from /root/.config/retroarch/cores/ppsspp_libretro.so
#2  0x00007ffff5c6ce87 in Atrac3Audio::Decode(unsigned char const*, int, int*, int, short*, int*) ()
   from /root/.config/retroarch/cores/ppsspp_libretro.so
#3  0x00007ffff5d9de03 in Atrac::SeekToSample(int) () from /root/.config/retroarch/cores/ppsspp_libretro.so
#4  0x00007ffff5d9df9d in Atrac::DecodeData(unsigned char*, unsigned int, unsigned int*, unsigned int*, int*) ()
   from /root/.config/retroarch/cores/ppsspp_libretro.so
#5  0x00007ffff5bda48f in void WrapU_IUUUU<&(sceAtracDecodeData(int, unsigned int, unsigned int, unsigned int, unsigned int))>() ()
   from /root/.config/retroarch/cores/ppsspp_libretro.so
#6  0x00007ffff5bcdd5b in CallSyscallWithoutFlags(HLEFunction const*) () from /root/.config/retroarch/cores/ppsspp_libretro.so
#7  0x00007fffe1ea73f8 in ?? ()
#8  0x0000000000000001 in ?? ()
#9  0x0000000000000001 in ?? ()
#10 0x0000000000000000 in ?? ()

It seems to segfault al the same point as ever, but not much to see because it is an optimized build.

anr2me commented 4 months ago

You didn't add -O0 -ggdb like previous?

vanfanel commented 4 months ago

You didn't add -O0 -ggdb like previous?

I did: I passed -DCMAKE_BUILD_TYPE=Debug and -O0 -ggdb. But if I do that, there are no segfaults at all.

JackSaleh commented 3 months ago

Please check out this Site

anr2me commented 3 months ago

What's this have anything todo with http request?

Please check out this Site https://stackoverflow.com/questions/1011339/!!!!8EROiLAuOi1WQDAcYMFOhLAEY8W3QFXcYc15LRbZYD1g

And the real url of that link is actually https://stackoverflow.com/questions/1011339/how-do-you-make-a-http-request-with-c So, what does the [Base64?] encoded !!!!8EROiLAuOi1WQDAcYMFOhLAEY8W3QFXcYc15LRbZYD1g supposed to do? (hopefully not something malicious)

JackSaleh commented 3 months ago

What's this have anything todo with http request?

Please check out this Site https://stackoverflow.com/questions/1011339/!!!!8EROiLAuOi1WQDAcYMFOhLAEY8W3QFXcYc15LRbZYD1g

And the real url of that link is actually https://stackoverflow.com/questions/1011339/how-do-you-make-a-http-request-with-c So, what does the [Base64?] encoded !!!!8EROiLAuOi1WQDAcYMFOhLAEY8W3QFXcYc15LRbZYD1g supposed to do? (hopefully not something malicious)

I copied this link from other website and wanted to put it on another issue. Thanks for helping, I will fix it now

vanfanel commented 4 days ago

Possibly related to this issue: https://github.com/libsdl-org/SDL/issues/11472

I have seen ffmpeg tries to use 3dnow, which in turn generates code with an instrution that doesn't exist on Intel chips. That would explain why passing alderlake optimization flags causes this issue.