Boost logo

Boost Users :

Subject: Re: [Boost-users] crash using boost::interprocess
From: nevergone . (wangyongxina_at_[hidden])
Date: 2011-11-03 09:27:40


HI, igaztanaga
I don't use any of experimental detail classes
like("emulation_recursive_mutex").
I'm using wmanaged_windows_shared_memory::find method to find a element,
and find method eventually
will call emulation_recursive_mutex::lock. The stack cannot see find due to
compile optimization.

The code is like this:

namespace BOOSTIP = ::boost::interprocess;

typedef struct _CACHE_ITEM
{
    BOOSTIP::offset_ptr<BYTE> CacheValue;
    ULONG CacheLength;
    ULONG CacheMaxLength;
    volatile BOOL CacheDirty;

    _CACHE_ITEM()
    {
        CacheValue = 0;
        CacheLength = 0;
        CacheMaxLength = 0;
        CacheDirty = FALSE;
    }

} CACHE_ITEM, *PCACHE_ITEM;

BOOL
CConfigCache::Read(__in LPCTSTR lpszName,
                   __out PVOID lpValue,
                   __in DWORD dwSize,
                   __out_opt PDWORD dwRetSize /*= NULL */)
{
    try
    {
        if (CanIAccessCache())
        {
            CScopeGuard<CMutex> guard(m_FunctionLock);

            //
            // ....... ignore some useless code
            //

            PCACHE_ITEM CacheItem = m_SharedMemory.find
<CACHE_ITEM>(lpszName).first;

            if (CacheItem)
            {
                if (dwSize >= CacheItem->CacheLength)
                {
                    if (dwRetSize)
                        *dwRetSize = CacheItem->CacheLength;

                    if (lpValue && CacheItem->CacheLength &&
CacheItem->CacheValue)
                    {
                        CopyMemory(lpValue, CacheItem->CacheValue.get(),
CacheItem->CacheLength);
                        return DecryptBuffer((LPBYTE)lpValue,
CacheItem->CacheLength);
                    }
                    else
                    {
                        return TRUE;
                    }
                }
                else if (dwRetSize)
                {
                    *dwRetSize = CacheItem->CacheLength;
                    return TRUE;
                }
                else
                {
                    return FALSE;
                }
            }
            else
            {
                ++m_ReadConfigCacheMissCount;
            }
        }

        return FALSE;
    }
    catch (BOOSTIP::interprocess_exception &)
    {
        EXCEPTION_OUT("CConfigCache::Read interprocess_exception\n");
        MakeCacheInvalid();
        return FALSE;
    }
    catch (CConfigCacheBaseException &)
    {
        EXCEPTION_OUT("CConfigCache::Read CConfigCacheBaseException\n");
        MakeCacheInvalid();
        return FALSE;
    }
}

Program random crash at :

PCACHE_ITEM CacheItem = m_SharedMemory.find<CACHE_ITEM>(lpszName).first;

I don't know why?

2011/11/3 <igaztanaga_at_[hidden]>

> El 02/11/2011 8:00, nevergone . escribió:
>
> Hello,
>>
>> I'm using boost::interprocess to share config information between
>> processes on windows platform. It random crash on custom pc.
>> I only have a minidump dump, here is the stack output by windbg:
>>
>
> It's hard to say, but using experimental detail classes
> ("emulation_recursive_mutex") is not supported. They are ongoin experiments.
>
> Ion
> ______________________________**_________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/**mailman/listinfo.cgi/boost-**users>
>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net