summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklin Wei <franklin@rockbox.org>2021-06-27 22:49:33 -0400
committerFranklin Wei <franklin@rockbox.org>2021-06-28 02:51:48 +0000
commitd1a92aafff55defefcb8cf8f4b045701325088b2 (patch)
tree1543685bcc513a2bd9e48c1564dad05597c52cf8
parent9f950d8bbf25995d0ba71ce2cd6cc9c0d3b91a9c (diff)
downloadrockbox-d1a92aafff55defefcb8cf8f4b045701325088b2.tar.gz
rockbox-d1a92aafff55defefcb8cf8f4b045701325088b2.zip
sdl: increase default worker thread size.
This fixes a mysterious, long-standing crash that's been bothering me on ipod6g for ages: a silent stack overflow in the sound mixing thread (which is triggered upon loading a new sound, apparently) will thrash the memory which is located directly before it in the address space. In this case, it was the SDL_ButtonState variable which stores the mouse button state that was being trashed. This was manifesting itself by making the player always run forward, since MOUSE2 is mapped to +forward by default. Fix this by quadrupling the stack size of SDL-spawned threads (not the main thread) from 1 KB to 4 KB. Change-Id: I2d7901b7cee1e3ceb1ccdebb38d4ac5b7ea730e1
-rw-r--r--apps/plugins/sdl/src/thread/rockbox/SDL_systhread.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/apps/plugins/sdl/src/thread/rockbox/SDL_systhread.c b/apps/plugins/sdl/src/thread/rockbox/SDL_systhread.c
index b9bd8735d3..d393e50e14 100644
--- a/apps/plugins/sdl/src/thread/rockbox/SDL_systhread.c
+++ b/apps/plugins/sdl/src/thread/rockbox/SDL_systhread.c
@@ -42,20 +42,25 @@ static void rbsdl_runthread(void)
42 SDL_RunThread(args); 42 SDL_RunThread(args);
43} 43}
44 44
45#define RBSDL_THREAD_STACK_SIZE (DEFAULT_STACK_SIZE * 4)
45#define MAX_THREAD 4 46#define MAX_THREAD 4
46static char names[MAX_THREAD][16]; 47static char names[MAX_THREAD][16];
47static long stacks[MAX_THREAD][DEFAULT_STACK_SIZE / sizeof(long)]; 48static long stacks[MAX_THREAD][RBSDL_THREAD_STACK_SIZE / sizeof(long)];
48 49
49int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) 50int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
50{ 51{
51 static int threadnum = 0; 52 static int threadnum = 0;
53
54 if(threadnum >= MAX_THREAD)
55 return -1;
56
52 snprintf(names[threadnum], 16, "sdl_%d", threadnum); 57 snprintf(names[threadnum], 16, "sdl_%d", threadnum);
53 58
54 while(global_args) rb->yield(); /* busy wait, pray that this works */ 59 while(global_args) rb->yield(); /* busy wait, pray that this works */
55 60
56 global_args = args; 61 global_args = args;
57 62
58 thread->handle = rb->create_thread(rbsdl_runthread, stacks[threadnum], DEFAULT_STACK_SIZE, 63 thread->handle = rb->create_thread(rbsdl_runthread, stacks[threadnum], RBSDL_THREAD_STACK_SIZE,
59 0, names[threadnum] /* collisions allowed? */ 64 0, names[threadnum] /* collisions allowed? */
60 IF_PRIO(, PRIORITY_BUFFERING) // this is used for sound mixing 65 IF_PRIO(, PRIORITY_BUFFERING) // this is used for sound mixing
61 IF_COP(, CPU)); 66 IF_COP(, CPU));