Repository navigation
Conversation
|
Core dump from a PS Vita 1000, built from
Files: redacted core dump · matching ELF. Parse with |
|
I sent the root-cause fix to VitaSDK: vitasdk/buildscripts#196. It's one newlib configure flag ( Because printf comes from newlib's libc at the app's final link, a VitaSDK image with that fix would fix this on the next app build. The mpv/FFmpeg packages wouldn't need rebuilding. Until then this PR works as a stopgap. Happy to close it once a fixed image is out, whichever you prefer. |
e948600 to
91a8dc8
Compare
VitaSDK's newlib is built without _WANT_IO_C99_FORMATS, so %zd, %zu, %td
and %jd are skipped without consuming their argument. Every following
argument shifts, and a later %s dereferences an integer. mpv's "Too many
packets in the demuxer packet queues" warning ("%s/%d: %zd packets...")
crashed the app this way after a seek.
Wrap newlib's string and stream formatters at link time and rewrite the
format first: z and t are dropped (size_t and ptrdiff_t are 32-bit like
int) and j becomes ll.
e84edf0 to
89df8e0
Compare
Split out of #289.
Seeking crashed in mpv's demuxer thread while formatting
" %s/%d: %zd packets, %zd bytes%s%s\n"(part of the "Too many packets in the demuxer packet queues" warning). VitaSDK's newlib is built without_WANT_IO_C99_FORMATS, soz,tandjaren't supported. The conversion is skipped without consuming its argument, every following argument shifts, and%sdereferenced the packet count (0x613f). Any mpv or FFmpeg message with%z…before a%scan crash the same way.Fix: wrap newlib's string and stream formatters at link time (
-Wl,--wrap=_svfprintf_r,_vfprintf_r,vfprintf) and rewrite the format first.zandtare dropped (size_t/ptrdiff_tare 32-bit likeinton the Vita) andjbecomesll. Verified in the final binary thatvsnprintf,snprintf,sprintfandfprintfgo through the wrapper.Found from a
psp2dmpcore dump on a PS Vita 1000. Tested on the Vita: the original crash case no longer crashes.