473,836 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Debug library crashes when linked with Release build

I just converted a solution from Visual Studio 2003 to Visual Studio
2005 and the Debug mode seems to be running just fine, but the Release
mode crashes on the following code:

std::ifstream in("myfile.txt" );
float value;
in >value; //The crash happens here in the getloc() function

The above code is actually from a library built in Debug mode that is
linked into the Release build of the executable. Does anyone have any
ideas of what could be causing this? Or how I could fix it (other than
switching the library to release mode, because that's currently not an
option)?

Thanks,
Dave
Apr 3 '08 #1
2 2712
The library is a static library?

There can be big problems linking to two versions of the same library.
Each will have its own set of internal variables, each will have its own
heap, one of them probably isn't even initialized, etc.

Mark
--
Mark Salsbery
Microsoft MVP - Visual C++
"Dave Johansen" <da**********@g mail.comwrote in message
news:cf******** *************** ***********@8g2 000hse.googlegr oups.com...
I just converted a solution from Visual Studio 2003 to Visual Studio
2005 and the Debug mode seems to be running just fine, but the Release
mode crashes on the following code:

std::ifstream in("myfile.txt" );
float value;
in >value; //The crash happens here in the getloc() function

The above code is actually from a library built in Debug mode that is
linked into the Release build of the executable. Does anyone have any
ideas of what could be causing this? Or how I could fix it (other than
switching the library to release mode, because that's currently not an
option)?

Thanks,
Dave
Apr 3 '08 #2
On Apr 10, 10:53 am, Dave Johansen <davejohan...@g mail.comwrote:
On Apr 9, 12:44 pm, Dave Johansen <davejohan...@g mail.comwrote:
On Apr 8, 3:45 pm, Dave Johansen <davejohan...@g mail.comwrote:
On Apr 8, 3:33 pm, "Ben Voigt [C++ MVP]" <r...@nospam.no spamwrote:
Dave Johansen wrote:
On Apr 8, 2:52 am, Ismo Salonen <Ismo.Salo...@c odeit.fiwrote:
>--snip--
>It does no more work because some classes have different sizes in
>debug vs. release mode. In debug mode ( _DEBUG defined) the classes
>contains extra fields for runtime checks. When release mode is
>compiled the classes memory footprint is smaller thanm in debug mode
>and debug mode writes memory locaations it should not ( those, now
>nonexistent debug variables).
>This worked in 2003 because it did not have such sophisticated debug
>helpers ( e.g iterator debugging). Using such combination
>(debug&release ) in same executable was never supported, it worked by
>pure luck (or if you *really* knew what to do) .
>br
>ismo
I think that the claim that it "worked by pure luck" is not correct.
It worked because there's no standard compliant reason why it
shouldn't. I understand that the debug mode now supports more advanced
You can't hide behind the standard here, because you defined _DEBUG, which
begins with underscore+capi tal letter and as such is reserved for the
compiler or library implementation. When you start messing with reserved
identifiers you are completely implementation-dependent.
Beyond that, the standard requires that the one-definition rule be
respected. Frequently this requires having the same macro definitions
across the whole project, including static libraries, because although ODR
doesn't apply to macros, macros control the definitions of other things.
checks and such, but there's no reason that this couldn't have been
done without maintain existing features (an additional preprocessor
directive that allowed the additional checks to be disable would have
solved the problem). I understand why things broke and the change
makes sense from a certain perspective, but claiming that it "has to
be that way" just isn't true.
I believe there are other macros (why would you need a new directive???)
that control the extra checks.
Dave
I agree 100% and I understand why things are the way they are, but I
still believe that they are this way by choice and not by some
external, uncontrollable force. The versions of Visual Studio prior to
2005 stand as a testament to this, because what I am trying to do was
allowed and functioned properly before Visual Studio 2005. I also
agree 100% that mixing debug and release libraries isn't recommended,
but that doesn't mean that it should be impossible.
Dave
I did a little more digging and it turns out that the iterator
debugging stuff can be disabled (which fixes the problem I was having)
by defining _HAS_ITERATOR_D EBUGGING as 0. You can read more about it
here:http://msdn2.microsoft.com/en-us/lib...39(VS.80).aspx
Thanks everyone for all of the help and advice,
Dave

I would like to make a correction and state that turning off the
iterator debugging didn't fix all of the problems that I was having
with mixing debug and release builds, so I guess that this is just a
semi-undocumented breaking change for Visual Studio 2005.

Dave
Hi,

I went through the same frustration when I moved our company software
from VS 2003 to VS 2005. I also tried to fix with the
_HAS_ITERATOR_D EBUGGING=0, but with partial success only. Is there a
way to "emulate" the VS2003 behavior with regards to mixing debug and
release CRT? From the thread below, I understand that the only clean
way out of my problems would be to revise all APIs and use only basic
data types in them...

Steve
Jun 27 '08 #3

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

Similar topics

2
399
by: Song | last post by:
Hi, gurus, I am new with visual studio... I am trying to build a standalone C++ project by MS visual C++, the problem that I have is: if compile it as "Release" version, it crashes by a certain combination of the operations, while if compile it as "debug" version, there is no problem. I also tried to "debug" the release version in the IDE, after seeing warning and choosing "debug anyway", there is no crash...I guess the problem has...
0
1522
by: Adam Tomjack | last post by:
I'm trying to embed Python 2.3.5 into a C++ application on Windows XP. When I build my app with debug symbols and link to a debug build of Python, then my program seems to crash most (but not all) of the time. Sometimes it crashes on startup, and sometimes at exit, sometimes not at all. I haven't seen it crash with non-debug builds of my app and Python. The release build runs my Python test code just fine. When the debug build doesn't...
2
1422
by: babyx | last post by:
The release build class library can only work with msvcr71d.dll and msvcp71d.dll exist. How to make this class library work on any machine without using the debug dlls? What are the project settings that i need to take note so that it will become a "real" release build without depending on the debug dll? Can anybody help? Posted Via Usenet.com Premium Usenet Newsgroup Services
5
5366
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 - ...
6
2282
by: Boni | last post by:
Dear all, I have following problem. I created a static libruary (mylib.lib). I compiled it with Multithreaded DLL runtime in release mode. Now I want to give out this library. But users who use it should be able to debug their programs (i.e. compile their programs in debug mode Multithreaded DLL DEBUG runtime ). But at link time following warning is shown and prog crashes. Do I have to
2
3567
by: kevinding | last post by:
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...
2
2382
by: Epetruk | last post by:
Hello, I have a problem where an application I am working on throws an OutOfMemoryException when I run it in Release mode, whereas it doesn't do this when I am running in Debug. The application is developed using C++/Managed C++ and built using VS 2003 under .NET framework 1.1. In Debug, it uses of up to 600Mb of memory, whereas in Release it only gets
4
6255
by: nmrcarl | last post by:
I'm trying to upgrade a large project from VS 6.0 to VS 2005. After fixing a lot of things that changed (mostly sloppy coding in the original project that VS2005 didn't allow), I got the release version to build successfully. Unfortunately, it crashes right away when I start it. So now I need to build the debug version. Unfortunately, the compiler gives innumerable error messages of the sort shown below. The #include file referenced...
6
9147
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
0
9825
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10600
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,...
0
10257
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9387
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7794
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
6981
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
5651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5829
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4459
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

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.