You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Threads created with NULL attributes get a 64 KiB stack on PS5 #228
On a PS5 Pro, firmware 12.00, a thread created with pthread_create(..., NULL, ...) gets a 64 KiB stack: pthread_attr_getstacksize() on a fresh pthread_attr_t returns 65536.
ShadowMountPlus creates its long-running threads with NULL attributes (sm_ampr_updater.c:953, sm_api_service.c:6317, sm_game_lifecycle.c:1191, sm_pkg_server.c:139/753/865, sm_shellcore_flags.c:775, sm_shellcore_service.c:1401, sm_storage.c:300, sm_api_service.c:5325, at 0b56a1c). Code on those threads has to fit in 64 KiB. One place that gets close: the /icon request is served on the API thread and copy_icon_file() in sm_icon_thumb.c:147 puts a 32 KiB buffer on the stack, below the request handler and any libpng/libjpeg frames.
Why I am reporting it: in a fork of ShadowMountPlus I added a 64 KiB stack buffer on the AMPR updater thread. On the console that read() failed with EFAULT, and when the buffer landed on mapped memory it corrupted another thread (a cache build stopped). Creating every thread with an explicit 1 MiB stack fixed it. I have not seen a crash in upstream ShadowMountPlus itself, so this is a risk report, not a reproduced bug.
What we used, in case it is useful:
staticinlineintsm_thread_create(pthread_t*thread, booldetached,
void*(*start)(void*), void*arg) {
pthread_attr_tattr;
intrc=pthread_attr_init(&attr);
if (rc!=0)
returnpthread_create(thread, NULL, start, arg);
(void)pthread_attr_setstacksize(&attr, 1024u*1024u);
if (detached)
rc=pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (rc==0)
rc=pthread_create(thread, &attr, start, arg);
(void)pthread_attr_destroy(&attr);
returnrc;
}
Moving the 32 KiB buffer to the heap would also do. I can open a PR with either if you want.
Activity