incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ravi Inampudi" <inamp...@roguewave.com>
Subject SourcePro ed 3 - deadlock situation
Date Tue, 01 Aug 2006 22:02:42 GMT

Hello,

A customer ran into a deadlock situation using SourcePro ed 3 with locale specific code. In
locale.h and locale.cpp, it is mentioned in the code that there was an attempt to fix a deadlock
scenario.  Source code snippets appended below. However, SourcePro ed 9 locale API seem to
have been redesigned. Could it be assumed that this deadlock problem was addressed at some
point?  How difficult is it to port these changes to SourcePro ed 3?
 
Regards,
Ravi
    
> /ms/dev/3rd/RWSourcePro/3.1/src/rw_buildspace/source/stdlib/locale.cpp:5
> 55
> 
>             if (__imp && __imp != _C_imp) {
>                 // HACK: we might (should?) be locked here but locale
> dtor
>                 // locks again - this despicable hack prevents a
> deadlock
>                 locale __loc (__imp);
>                 __loc._C_install_facet (__facet, __id);
>                 __loc._C_imp = 0;   // set to 0 to prevent dtor from
> locking
>                 --__imp->_C_ref_count;   // decrement manually
>             }
> 
> /ms/dev/3rd/RWSourcePro/3.1/src/rw_buildspace/include/rw/_locale.h: 170
>     ~locale () {
>         // HACK: _C_imp should normally never be 0; internally, though,
>         // it's set to 0 in locale::_C_make_facet to prevent a deadlock
>         if (_C_imp && 0 == _RWSTD_ATOMIC_PREDECREMENT
> (_C_imp->_C_ref_count,
>  
> _C_imp->_C_mutex))
>             delete _C_imp;
>     }
> 
> /ms/dev/3rd/RWSourcePro/3.1/src/rw_buildspace/include/rw/_locale.h: 510
> // same as above but not guarded; called during initialization
> // of the num_get<> and num_put<> facets (this is a hack)
> inline const locale::facet&
> locale::_C_unsafe_use_facet (const id &__id, bool __implicit, category
> __cat,
>                              __facet_maker_func __maker) const
> {
>     _RWSTD_ASSERT (0 != _C_imp);
> 
>     const facet *__facet = _C_get_facet (__id);
> 
>     if (!__facet)
>         __facet = _C_make_facet (__id, __implicit, __cat, __maker);
> 
>     _RWSTD_ASSERT (__facet);
> 
>     return *__facet;
> }

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message