]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix possible core-dump as seen in regression testing
authorMarco van Wieringen <mvw@planets.elm.net>
Mon, 31 Jan 2011 12:35:18 +0000 (13:35 +0100)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:39:56 +0000 (14:39 +0200)
Thread 2 (Thread 1132489024 (LWP 21031)):
lockmgr.c:939

Dereference jcr->db after release of jcr will lead to disaster.

bacula/src/dird/msgchan.c

index e6cdc33e5299a58688656ec36ec90a91a9f67491..816df58bac7fc9e222ae211783181cd8cbde7929 100644 (file)
@@ -353,15 +353,15 @@ bool start_storage_daemon_message_thread(JCR *jcr)
 extern "C" void msg_thread_cleanup(void *arg)
 {
    JCR *jcr = (JCR *)arg;
-   db_end_transaction(jcr, jcr->db);       /* terminate any open transaction */
+   db_end_transaction(jcr, jcr->db);        /* terminate any open transaction */
    jcr->lock();
    jcr->sd_msg_thread_done = true;
    jcr->SD_msg_chan = 0;
    jcr->unlock();
    pthread_cond_broadcast(&jcr->term_wait); /* wakeup any waiting threads */
    Dmsg2(100, "=== End msg_thread. JobId=%d usecnt=%d\n", jcr->JobId, jcr->use_count());
-   free_jcr(jcr);                     /* release jcr */
-   db_thread_cleanup(jcr->db);               /* remove thread specific data */
+   db_thread_cleanup(jcr->db);              /* remove thread specific data */
+   free_jcr(jcr);                           /* release jcr */
 }
 
 /*