This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCHES][RFC] Fix a deadlock bug in static variable initialization


On 6/8/07, Doug Kwan (?振德) <dougkwan@google.com> wrote:
Hi,

    Attached here is patches to both gcc and libstdc++-v3 to fix a
deadlock problem in function static variables. The patches have been
applied to gcc-4.1.0 and tested on i486 with a full bootstrap. I've
also test the trunk it is not stable enough to do a full bootstrap.

Care to explain the deadlock problem? Also the ChangeLog is formatted incorrectly (see below).

Richard.

2007-06-08 Doug Kwan <dougkwan@google.com>

        * gcc/gthr-posix.h (__gthread_cond_broadcast, __gthread_cond_wait,
          __gthread_cond_wait_recursive, __gthread_self, __gthread_equal):
          Add to extend interface for POSIX conditional variables.
          (__GTHREAD_HAS_COND): Macro defined to signify support of
          conditional variables.
        Likewise
        * gcc/gthr-single.h (__gthread_cond_broadcast, __gthread_cond_wait,
          __gthread_cond_wait_recursive, __gthread_self, __gthread_equal):
          Add to extend interface for POSIX conditional variables.
        * gcc/gthr.h: Update comments to document new interface.

these should be written as


* gthr-posix.h (...

omitting gcc/ (and they go to the gcc/ChangeLog).  Also following
lines should be indented a single tab, aligned to the '*'.

        * libstdc++-v3/include/ext/concurrent.h (class __mutex,
          class __recursive_mutex): Add new method gthread_mutex to access
          inner gthread mutex.

omit libstdc++-v3/ (and they go to libstdc++-v3/ChangeLog


          [__GTHREAD_HAS_COND] (class __concurrence_broadcast_error,
          class __concurrence_wait_error, class __cond): Add.
        * guard.cc (random_level, new_skip_list_node, skip_list_search_internal,

where's this file?


          new_skip_list, skip_list_insert_key, skip_list_delete_key,
          skip_list_search_key). Add to implement skip list to map guard
          variables and thread ID's.
          (recurisve_push, recursive_pop): Delete.
          (init_in_progress_flag, set_init_in_progress_flag): Add to
          replace recursive_push and recursive_pop.
          (throw_recursive_init_exception): Add.
          (acquire, __cxa_guard_acquire, __cxa_guard_abort and
          __cxa_guard_release): [__GTHREAD_HAS_COND] Use a conditional
          for synchronization of static variable initialization.
          The global mutex is only held briefly when guards are
          accessed. [!__GTHREAD_HAS_COND] Fall back to the old code,
          which deadlocks.
        * testsuite/thread/guard.cc: Add new test. It deadlocks with the
          old locking code in libstdc++-v3/libsup++/guard.cc.





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]