473,714 Members | 2,500 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

crash in release build, but it works on debug build

Hi All,

We meet an evil condition for our project. Our project has 3 layers.
A C# layer to do some business logic, and Managed C++ layer translate
managed values to native ones or vice verse.(vs2005, /clr:oldSyntax) .
UI layer are written in native C++.

Currently, we meet a random crash bug in release build. It is ok in
debug build. If we replace the managed c++ dll with the debug one, it
works also. So we think there must be something wrong in Managed C++
layer.

We intensively convert System::String to TCHAR * in Managed C++
layer. The code snippet is as belows:

TCHAR * strName = NULL;
System::String * Name = dv->Name; //get the value from C# layer
if(Name)
{
nLength = Name->Length;
strName = new TCHAR[nLength+1];
ptr = Marshal::String ToHGlobalUni(Na me);
if(ptr != IntPtr::Zero)
{
lstrcpy(strName ,
reinterpret_cas t<__wchar_t*>(s tatic_cast<void *>(ptr)));
}
}

The crash are random. But all crashes are occur after some code try
to alloc some native memory.

Call stack in Crash Scenario 1
Unhandled exception at 0x77fcca14 (NTDLL.DLL) : 0xC0000005: Access
violation writing location 0x00000000.

NTDLL.DLL!_Rtlp CoalesceFreeBlo cks@16
NTDLL.DLL!_Rtlp ExtendHeap@8
NTDLL.DLL!_RtlA llocateHeap@12
msvcr80.dll!mal loc
msvcr80.dll!ope rator new
05f1d90c()
mscorwks.dll!Se curityPolicy::I sDefaultThreadS ecurityInfo()(
...

Call stack in Crash Scenario 2
Unhandled exception at 0x77fcc024 (NTDLL.DLL): 0xC0000005: Access
violation writing location 0x00000052.

NTDLL.DLL!_RtlA llocateHeap@12
KERNEL32.DLL!_L ocalAlloc@8
MFC71u.dll!CNoT rackObject::ope rator new
MFC71u.dll!CThr eadSlotData::Se tValue
MFC71u.dll!CThr eadLocalObject: :GetData
MFC71u.dll!AFX_ MAINTAIN_STATE2 ::AFX_MAINTAIN_ STATE2
xxxxxx.dll!02c1 0101() (it is our UI dll)
...

But when I use Performance Monitor, the private heap is used
little. Also the usage of CLR memory is very low also. What is happen
to the memory heap?

Do you know what is wrong to Managed C++ module? Is there a good
tool to monitor the memory to the Interop program? Or there are some
special compiler setting for release build.

Any help are appreciated.

Thanks.

ding

Jul 14 '06 #1
2 3560

Such call stacks usually mean that the native heap is corrupted.
You can try to enable PageHeap to detect the place where
the corruption occurs.
http://www.debuginfo.com/tips/userbpntdll.html

Regards,
Oleg
[VC++ MVP http://www.debuginfo.com/]

Jul 14 '06 #2
Hi Oleg,

We had solved the bug. The developer had wrote some code that cause
buffer overflow. We are very new with this kind of bug in Managed C++,
it always crashed when any code want to allocate the memory. We found
Heap Manager is corrupt already, but we don't think it more.

Thanks very much for your kindly help.

Regards,

ding
Oleg Starodumov 写道:
Such call stacks usually mean that the native heap is corrupted.
You can try to enable PageHeap to detect the place where
the corruption occurs.
http://www.debuginfo.com/tips/userbpntdll.html

Regards,
Oleg
[VC++ MVP http://www.debuginfo.com/]
Jul 17 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1494
by: KeithO | last post by:
Problem: App works OK in debug both in VS.Net and build version. Also OK as release version in VS.net Not working as release version build. Gets to this line of code: (private func called from sub Main()) da.Fill(crms_ds_ParcelList, "rfaPRef") then stops (does not hang) just stops...
2
3985
by: | last post by:
Hi, I'm experiencing a bizar problem with MS VC++, and just can't figure out what's going on. I Build a solution that compiles pretty well, it works good when I launch it in the Visual C++ Editor (F5 or shift+ F5) but the .exe file generated in a release mode doesn't work properly ! Anye clue ??
5
5357
by: David++ | last post by:
Hi there, I have built a DLL in Visual C++ 6. When I build the DLL it builds fine for the debug version of the DLL (and this DLL works fine), however, I seem unable to build a Release version of the DLL. If I do a 'Batch Build' and select both Debug and Relase versions for building it will build the debug version but throws up errors for the Release version. For example, the output I get for a Batch Build is this - ...
3
2889
by: Steve Franks | last post by:
I'm using Visual Studio 2005 RC and cannot figure out how to produce a "release" build. Am I doing something wrong? I'm wondering if perhaps MS locked out the ability to produce a release build when using the RC since it does not have a go-live license? Or maybe I'm just doing something wrong. I do not want to go live with a release build. Rather I just want to test locally to see if there is a performance difference and also to...
6
1761
by: George M. Garner Jr. | last post by:
VC8.0 crashes while compiling boost-1.33.1 serialization library (or any other library that includes the serialization headers) if code analysis (/analyze) is enabled. This problem did not occur with prior beta releases of boost-1.33.1 or with the VC8.0 beta. You may want to consider whether the crash of a dependent tool should be allowed to cause the entire VC8 IDE to hang or whether this might be a design defect. Given the recent price...
6
9141
by: Andrew Rowley | last post by:
I am having trouble getting debug and release builds to work properly with project references using C++ .NET and Visual Studio 2003. I created a test solution, with a basic Windows form C++ project. I then add a class library, and add a reference to this project in the first project. When I do a release build, I see the following in the output from the DLL compile: /OUT:"C:\Documents and Settings\Andrew\My Documents\Visual Studio
5
3396
by: Jonas Hallgren | last post by:
Hello, Is there any general tips on how to solve this problem: my Debug version runs fine but when I do a Release version I get error messages!? I'm hoping it is a simple option somewhere or a flag I can set... Regards, Jonas
1
1691
by: Duncan Smith | last post by:
Hi All, Grateful if anyone has any suggestions here? I have a VS2005 MFC app which hosts several types of views in CFrameWnds - one of which contains a managed control hosted in a CWinFormsView Everything works well on my dev pc (and other peoples dev pcs), but when I try and instantiate the managed view on a target-pc (no compilers, etc) there's an exception thrown followed by program termination.
3
1846
by: Russ | last post by:
I have a Web Service that was originally created with .NET VC 2003, and subsequently converted to the 2005 version. It works fine when built as a debug version, and run on the workstation it was built on. Now I want to build a release version so I can deploy it to Windows 2003 server. This project is compiled with "/clr:oldSystax". I've run into several problems and I am not sure all of the things I am discovering are related. Any help...
0
8801
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8707
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9174
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6634
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5947
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4725
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3158
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2110
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.