[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rockbox-cvs
Subject:    maemo port: Fix startup crash exposed by audio thread refactoring
From:       gerrit () rockbox ! org
Date:       2014-12-20 1:28:13
Message-ID: 201412200128.sBK1SDJS002601 () giant ! haxx ! se
[Download RAW message or body]

commit c55be3b83ae2e23754a93ee8676d76604c0a5f8e
Author: Thomas Jarosch <tomj@simonv.com>
Date:   Sat Dec 20 02:06:24 2014 +0100

    maemo port: Fix startup crash exposed by audio thread refactoring
    
    The refactoring of the audio thread in this commit
    -----------------------------------------------
    commit 5857c44017a1641fce7f00da7f16c143daacbaf6
    Author: Michael Sevakis <jethead71@rockbox.org>
    Date:   Fri May 31 02:41:02 2013 -0400
    
        Refactor audio thread to run both recording and playback.
    -----------------------------------------------
    
    moved pcm_init() next to dsp_init() in apps/main.c:init().
    Before that pcm_init() was called by audio_init().
    
    Unfortunately the maemo init code didn't properly
    wait until the maemo thread was fully initialized,
    leading to dangling pointers when the code called
    by pcm_init() tried to access maemo's variables.
    
    Fix it by refactoring the "very fast shutdown" semaphore
    to wait until maemo is initialized in any case.
    
    This should also fix very rare rockbox crashes
    on startup that I got once a year or so.
    The new code has been tested by a script that
    starts and kills rockbox after one second.
    
    Change-Id: I464efce5f2b71ca869c72a5bc578555b8022e459

diff --git a/firmware/target/hosted/sdl/system-sdl.c b/firmware/target/hosted/sdl/system-sdl.c
index aa322dd..37580ed 100644
--- a/firmware/target/hosted/sdl/system-sdl.c
+++ b/firmware/target/hosted/sdl/system-sdl.c
@@ -159,28 +159,26 @@ static int sdl_event_thread(void * param)
     if (background && picture_surface != NULL)
         SDL_BlitSurface(picture_surface, NULL, gui_surface, NULL);
 
-    /* let system_init proceed */
-    SDL_SemPost((SDL_sem *)param);
-
 #if (CONFIG_PLATFORM & PLATFORM_MAEMO)
-    /* Start maemo thread: Listen to display on/off events and battery monitoring */
+    /* start maemo thread: Listen to display on/off events and battery monitoring */
     wait_for_maemo_startup = SDL_CreateSemaphore(0); /* 0-count so it blocks */
     SDL_Thread *maemo_thread = SDL_CreateThread(maemo_thread_func, wait_for_maemo_startup);
+
+    SDL_SemWait(wait_for_maemo_startup);
+    SDL_DestroySemaphore(wait_for_maemo_startup);
 #endif
 
+    /* let system_init proceed */
+    SDL_SemPost((SDL_sem *)param);
+
     /*
      * finally enter the button loop */
     gui_message_loop();
 
-#if (CONFIG_PLATFORM & PLATFORM_MAEMO)
-    /* Ensure maemo thread is up and running */
-    SDL_SemWait(wait_for_maemo_startup);
-    SDL_DestroySemaphore(wait_for_maemo_startup);
-
 #if (CONFIG_PLATFORM & PLATFORM_MAEMO5)
     pcm_shutdown_gstreamer();
 #endif
-
+#if (CONFIG_PLATFORM & PLATFORM_MAEMO)
     g_main_loop_quit (maemo_main_loop);
     g_main_loop_unref(maemo_main_loop);
     SDL_WaitThread(maemo_thread, NULL);
_______________________________________________
rockbox-cvs mailing list
rockbox-cvs@cool.haxx.se
http://cool.haxx.se/cgi-bin/mailman/listinfo/rockbox-cvs

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic