[patch] Fix for PR gdb/10757
Pedro Alves
pedro@codesourcery.com
Tue Oct 27 09:43:00 GMT 2009
On Tuesday 27 October 2009 00:41:24, Paul Pluzhnikov wrote:
>
> static __volatile__ int thread_iteration_in_progress;
> static __volatile__ int thread_creation_in_progress;
>
> __pthread_create_2_1 (...)
> {
> while (thread_iteration_in_progress) nanoslep ...;
> atomic_increment(&thread_creation_in_progress);
> ... create new thread, put it on thread list ...
> atomic_decrement(&thread_creation_in_progress);
> return ...
> }
>
> and in
>
> td_ta_thr_iter ()
> {
> set thread_iteration_in_progress in the inferior to 1
> while (thread_creation_in_progress in inferior > 0)
> nanosleep ...
>
> iterate over the thread lists ...
>
> set thread_iteration_in_progress in inferior to 0
> }
>
This does make the race window narrower, but it doesn't
completely kill it, as new threads could have passed the
thread_iteration_in_progress check already as gdb enters the
thread iteration loop.
--
Pedro Alves
More information about the Gdb-patches
mailing list