CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Join Date
    Apr 2004
    Posts
    57

    Serialization crashing only release version! Help!

    Hi!

    I'm working on a mfc mdi app. I have implemented a serialization routine in order to save / open files. While it works great in Debug version (it's a pretty simple code), it crashes the app in Release version when trying to open a file.

    Release version works great when saving, but you can't open a file without a crash. In fact, a file saved by the release version can be opened by the debug one.

    The fun fact is that I removed all the code from the Serialize func in my CDocument derived class (except CDocumment::Serialize(ar) call) and the app still crashes!

    As a note, I have checked that the crash occurs after the serialization process has finished, I can guess that when trying to show the window...

    I can't find an explanation for this anywhere, so any info will be really appreciated! Thanks in advance!

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Serialization crashing only release version! Help!

    Take a look at this J.Newcomer's article:Debug vs. Release

  3. #3
    Join Date
    Apr 2002
    Location
    St.Petersburg, Russia
    Posts
    714

    Re: Serialization crashing only release version! Help!

    Sounds like "Help me, my code works fine in debug, but not in release. Any ideas?"... If you will not provide your code - probably nobody can help you.

    The only thing I can suggest - is to add some MessageBox() calls to find a place where crash occurs. Or you can use a file to log events in. Don't forget to flush file buffer after every write.
    With best wishes, Alexander Hritonenkov

  4. #4
    Join Date
    Aug 2002
    Location
    Cluj-Napoca,Romania
    Posts
    3,496

    Re: Serialization crashing only release version! Help!

    1. enable the debug information on the release mode ( search the forum's FAQ for details)
    2. run you app until it crahses
    3. check where and why crashes
    Har Har

  5. #5
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Serialization crashing only release version! Help!

    Quote Originally Posted by Scrambler
    The only thing I can suggest - is to add some MessageBox() calls to find a place where crash occurs. Or you can use a file to log events in.
    There's no need for message boxes or logfiles - you can debug a release build. Hava a look at this FAQ.

  6. #6
    Join Date
    Apr 2002
    Location
    St.Petersburg, Russia
    Posts
    714

    Re: Serialization crashing only release version! Help!

    Quote Originally Posted by gstercken
    There's no need for message boxes or logfiles - you can debug a release build.
    Yes, I know. But sometimes some messageboxes is a quicklier solution than debugging the release build.
    And I can say more - in my current project there was a problem like this - i tried to debug release build, but every time I added the debug info, program crash disappears! So the only way was to debug it via log.
    And, of course, when you developing, for example, for PocketPC - debug on remote machine is so slow...
    With best wishes, Alexander Hritonenkov

  7. #7
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Serialization crashing only release version! Help!

    Quote Originally Posted by Scrambler
    And I can say more - in my current project there was a problem like this - i tried to debug release build, but every time I added the debug info, program crash disappears!
    That seems near to impossible - if you choose to use the program database for the debug info (which is the default), your object code isn't even changed - it's exactly the same like in a release build without debug info, and can't behave differently.

  8. #8
    Join Date
    Aug 2002
    Location
    Cluj-Napoca,Romania
    Posts
    3,496

    Re: Serialization crashing only release version! Help!

    Quote Originally Posted by gstercken
    That seems near to impossible - if you choose to use the program database for the debug info (which is the default), your object code isn't even changed - it's exactly the same like in a release build without debug info, and can't behave differently.
    Maybe it had to do with other settings, like "Optimisations".
    Har Har

  9. #9
    Join Date
    Apr 2004
    Posts
    57

    Re: Serialization crashing only release version! Help!

    Wow this is pretty strange!

    First of all, I loaded a previous version of the project, in which there was not any Serialization yet implemented (so loading a file has no effect over the document, which has the default constructor needed) and the problem persists.

    I have tried to debug the release version, however, as far as I try to debug it, the problem dissapears (I have not placed any breakpoint). Now, run the same release version and you obtain the crash again. What does it mean? That I can't debug in order to find where the crash occurs...

    I also tried the AfxMessageBox approach, but the crash seems to happen outside of my own code.

    I can't really imagine where the failure can be, since all this is happening with no serialization code!!!

    Anyway, thanks to all!

  10. #10
    Join Date
    Aug 2002
    Location
    Cluj-Napoca,Romania
    Posts
    3,496

    Re: Serialization crashing only release version! Help!

    Try to isolate the crash as narrow as possible. What is the last thing that you do before the crash happens ( menu click, button click etc).
    Har Har

  11. #11
    Join Date
    Apr 2004
    Posts
    57

    Re: Serialization crashing only release version! Help!

    As far as I try to open a previously saved file, the app crashes. The serialization code works fine, so it seems to occur when trying to show the window.

    Can't imagine a solution for this...

  12. #12
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Serialization crashing only release version! Help!

    Quote Originally Posted by jettocrack
    I have tried to debug the release version, however, as far as I try to debug it, the problem dissapears (I have not placed any breakpoint). Now, run the same release version and you obtain the crash again. What does it mean? That I can't debug in order to find where the crash occurs...
    That shouldn't be a problem: While a program might behave differently when run in the debugger (different memory layout, timing etc.), you can still use just-in-time debugging. So run your app (the release build with the debug info). When it crashes, you get a message box which informs you about the problem. Click the "Debug" button in that ´message box - that will start the VC++ IDE and load your source code into the debugger, pointing at the line where the crash occured.

  13. #13
    Join Date
    Apr 2004
    Posts
    57

    Re: Serialization crashing only release version! Help!

    I'm trying this, however, since Visual Studio .NET is also installed on the computer (my project is a VS6 app), the default debugger is .NET, and don't know how to change it.

    I have no idea of the .NET arch, altough it seems it's possible to debug with it...

    Does anybody know how to restore VS6 as the default debugger?

  14. #14
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Serialization crashing only release version! Help!

    Quote Originally Posted by jettocrack
    Does anybody know how to restore VS6 as the default debugger?
    I'm not sure if this works (since I don't have a parallel installation) - but you could try to go to Options / Debug and turn off "Just-In-Time Debugging" (in VS7, of course).

  15. #15
    Join Date
    Apr 2004
    Posts
    57

    Re: Serialization crashing only release version! Help!

    I finally solved the problem, it was simpler than I can thought...

    What I can't imagine is how the app managed to work in debug mode....

    Thanks to all, can't imagine how useful your help has been!

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured