3

I've the following piece of code

try
{
    // Vector creation in shared memory. The shm must exist.
    m_pxShm = new managed_shared_memory(open_only, pcShmName);
    m_pxShm->construct<T>(pcVecName)[iSize]();  // THROW EXCEPTION <==
    m_xVectorPair = m_pxShm->find<T>(pcVecName);

    if (0 == m_xVectorPair.first)
    {
        throw std::exception();
    }
}
catch (std::exception)
{
    throw SharedMemoryVectorBadAllocException();
}

The SharedMemoryVectorBadAllocException use std::exception as base class. When I run this piece of code, the line with the 'construct' method throws an exception (because I create a vector bigger than shared memory). But the thrown exception is not handled, and the application crashes. Even if I debug it, line by line, the exception is not handled by the catch statement. I've tried to use as catch argument std::exception, interprocess_exception, ... and so on, without success. How can I handle the exception ? I'm using Visual studio 2010.

souki
  • 1,305
  • 4
  • 23
  • 39
Jepessen
  • 11,744
  • 14
  • 82
  • 149

0 Answers0