Visual C ++ app dumps before main in Release but works fine in Debug

On release, it fails with an unhandled exception: std :: length error.

The call stack looks like this:

msvcr90.dll!__set_flsgetvalue()  Line 256 + 0xc bytes   C
msvcr90.dll!__set_flsgetvalue()  Line 256 + 0xc bytes   C
msvcr90.dll!_getptd_noexit()  Line 616 + 0x7 bytes  C
msvcr90.dll!_getptd()  Line 641 + 0x5 bytes C
msvcr90.dll!rand()  Line 68 C
NEM.exe!CGAL::Random::Random()  + 0x34 bytes    C++
msvcr90.dll!_initterm(void (void)* * pfbegin=0x00000003, void (void)* * pfend=0x00345560)  Line 903 C
NEM.exe!__tmainCRTStartup()  Line 582 + 0x17 bytes  C
kernel32.dll!7c817067()     

      

Anyone have any hints?

+1


source to share


4 answers


Examining the stack dump:

InitTerm is simply a function that loops through a list of other functions and performs each step - this is used, among other things, for global constructors (on startup), global destructors (on shutdown), and atexit lists (also on shutdown).

You are linking to CGAL since this one CGAL::Random::Random

in your stack dump is related to the fact that CGAL defines a global variable with a default_random

type name CGAL::Random::Random

. This is why your error happens before main is built default_random

.

From the CGAL source, it all calls standard C srand(time(NULL))

and then local get_int

, which in turn calls standard C rand()

to get a random number.

However, you don't make it to the second stage, since your stack dump is still within srand()

.

It looks like it is converting the stream to a tape lazily, i.e. this is the first time you tried to do something in a stream and needs to configure the fiber optic storage before proceeding.

So, a few things to try and investigate.



1 / Are you using this code on pre-XP? I believe there was fiber optic storage ( __set_flsgetvalue

) installed in XP . This is a long shot, but we still have to clean it up.

2 / Do you need to associate with CGAL? I am assuming your application needs something in the CGAL libraries, otherwise don't link with it. It might be a hangover from another project file.

3 / If you do , use CGAL, make sure you are using the latest version. Since version 3.3 it supports dynamic linking, which should prevent the possibility of mixing different versions of a library (both static / dynamic and debug / unfinished).

4 / Can you try to compile VC8? Supported CGAL platforms have NOT , but include VC9 (VS2008). You may need to keep an eye on this with the CGAL team to make sure they are working on this support.

5 / Finally, do you have Boost installed? This is another long shot but still worth a look.

If none of these suggestions help, you will have to wait until someone else recognizes me, but I'm afraid.

Good luck.

+3


source


Failure before main () is usually caused by a bad constructor on a global or static variable.



Similar to the constructor for the Random class .

0


source


Do you have a global or static variable of type Random? Is it possible that you are trying to build it before the library it was initialized in correctly?

Note that the order in which globals and static variables are built is not fixed and may change from debug to release.

0


source


Could you please clarify the error you are getting? (an unhandled std :: length exception sounds strange - I've never heard of it)

As far as I know, FlsGetValue automatically falls back to the TLS peer if the FLS API is not available.

If you're still stuck, grab the .dmp of your process at the time of the crash and post it (use any of the many free download services - and give us a link) (Sounds like a missing feature in SO-source / data file exchange?)

0


source







All Articles