Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Optimisation causing crash

Reply
 
Old 04-09-2008   #1 (permalink)
ropo


 
 

Optimisation causing crash

I have the following C++

// unmanaged code
func()
{
// this class is principly data
CMyClass Obj();

do
{
CallManagedWrapper(&Obj);
} while(...) // crashes second time around
}

// manage code
CallManagedWrapper( CMyClass* pObj)
{
CMyManagedClass^ ManObj = gcnew CMyManagedClass(pObj);
}

CMyManagedClass(CMyClass* pObj)
{
// copy data from unmanaged code
m_dbA = pObj->m_dbA;
}

With optimisation off around func() there is no crash with it on, the
second time the CMyManagedClass construtor accesses pObj it crashed.

so.

#pragma optimize("", off)
// unmanaged code
func()
{
// this class is principly data
CMyClass Obj();

do
{
CallManagedWrapper(&Obj);
} while(...) // crashes second time around
}
#pragma optimize("", on)

there is no problem

also there is no problem if I do this:

// unmanaged code
func()
{
// this class is principly data
CMyClass* pObj = new CMyClass();
CMyClass& Obj = *pObj;

do
{
CallManagedWrapper(&Obj);
} while(...) // crashes second time around
delete pObj;
}

I am worried that this problem may occur elsewhere so am seeking an
understanding of the problem.

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
WMDC Causing PFN List Corrupt crash? Vista General
RICOH Camera Drivers Causing Crash Vista hardware & devices
Vista (or ??) causing Internet to crash Vista General
XPS viewer causing vista display to crash... Vista General
Media Center Causing Crash in VistaB2 Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46