[PATCH] Possible threads race condition in src/alarm.c
James E Keenan
jkeen at verizon.net
Wed Aug 29 11:01:53 UTC 2012
On 8/28/12 10:34 AM, Andy Dougherty wrote:
> I've never really done any threads programming, so I could be quite off
> here, but it looks to me as if there's a race condition in src/alarm.c in
> the threads branch. Specifically, Parrot_alarm_init() creates a thread
> that checks sleep_cond before it initializes sleep_cond. (Similar remarks
> hold for alarm_lock.)
>
> Does this patch look appropriate?
>
> diff --git a/src/alarm.c b/src/alarm.c
> index 298387f..0ec6a1f 100644
> --- a/src/alarm.c
> +++ b/src/alarm.c
> @@ -56,9 +56,9 @@ Parrot_alarm_init(void)
> {
> ASSERT_ARGS(Parrot_alarm_init)
> Parrot_thread thread;
> - THREAD_CREATE_JOINABLE(thread, Parrot_alarm_runloop, NULL);
> MUTEX_INIT(alarm_lock);
> COND_INIT(sleep_cond);
> + THREAD_CREATE_JOINABLE(thread, Parrot_alarm_runloop, NULL);
> }
>
> /*
>
I applied this patch to the threads branch locally and -- for the very
first time -- achieved a PASS to 'make test' on Darwin/PPC.
doughera++
See: Smolders 30903 and 30918.
Thank you very much.
jimk
More information about the parrot-dev
mailing list