[SDL2 2.0.10] free(): invalid pointer / crashes ES after using Retroarch

Well when I try to run libretro cores on my RPi3 by using Retroarch 1.7.7 with Emulationstation 2.8.4 & SDL2 2.0.10 then it always crashes once you exit Retroarch. This does not happen with SDL2 2.0.9 so I’m not exactly sure where I should start to dig :thinking: because it works fine on Generic & Rockchip builds. ES also only crashs when you start lr cores but runs standalone stuff like amiberry fine and returns to the ES frontend as you would expect.

I use a LibreELEC image as base for my builds. https://github.com/5schatten/LibreELEC-RR

I did a bisect & it looks like ES starts to crash after this commit https://github.com/spurious/SDL-mirror/commit/a5a5e2cbd3f3aa2bc1406128fb1b13870a133c5a

strace output:

writev(2, [{iov_base="free(): invalid pointer", iov_len=23}, {iov_base="\n", iov_len=1}], 2free(): invalid pointer
) = 24
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x76ef3000
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1], [], 8) = 0
getpid()                                = 3106
gettid()                                = 3106
tgkill(3106, 3106, SIGABRT)             = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=3106, si_uid=0} ---
+++ killed by SIGABRT +++
Aborted

journalctl:

Aug 19 09:58:35 raspi3 emulationstation.start[773]: free(): invalid pointer
Aug 19 09:58:36 raspi3 emulationstation.start[773]: Aborted

Please file this as bug at https://bugzilla.libsdl.org/ so it wouldn’t be forgotten.

Already done https://bugzilla.libsdl.org/show_bug.cgi?id=4769 but I couldn’t add it till now because my account was on hold for posting details about this bug :roll_eyes: