Race condition prevents working completely

Bug #158573 reported by Ignacy Gawędzki
2
Affects Status Importance Assigned to Milestone
xmms-alarm (Ubuntu)
Won't Fix
Undecided
Unassigned

Bug Description

Binary package hint: xmms-alarm

There is a race condition at the start of alarm_start_thread() when the condition of the while loop is first evaluated, since the global start_tid may not yet have been initialized with the return value of alarm_thread_create(). This access to start_tid should be protected by a mutex.

Here comes the patch :

diff -ru xmms-alarm-0.3.7/src/alarm.c xmms-alarm-0.3.7-repaired/src/alarm.c
--- xmms-alarm-0.3.7/src/alarm.c 2005-04-09 02:20:12.000000000 +0200
+++ xmms-alarm-0.3.7-repaired/src/alarm.c 2007-10-30 07:50:54.000000000 +0100
@@ -57,6 +57,7 @@
 static pthread_t start_tid; /* thread id of alarm loop */
 static pthread_t stop_tid; /* thread id of stop loop */
 static pthread_mutex_t fader_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t start_lock = PTHREAD_MUTEX_INITIALIZER;

 static GeneralPlugin alarm_plugin;

@@ -880,6 +881,9 @@
    unsigned int play_start = 0;
    guint today;

+ pthread_mutex_lock(&start_lock);
+ pthread_mutex_unlock(&start_lock);
+
    while(start_tid != 0)
    {
      /* sit around and wait for the faders to not be doing anything */
@@ -1080,7 +1084,9 @@
    alarm_read_config();

    /* start the main thread running */
+ pthread_mutex_lock(&start_lock);
    start_tid = alarm_thread_create(alarm_start_thread, NULL, 1);
+ pthread_mutex_unlock(&start_lock);

Please apply and notify upstream (if any still alive).

Tags: patch
Revision history for this message
Daniel T Chen (crimsun) wrote :

Ubuntu no longer ships xmms-alarm.

Changed in xmms-alarm:
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.