• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

Crashes in Debug(random) but not release

eVC++ 4.0 Pocket PC using MFC, and IAnywhere

I have an issue when running in debug mode, the program will "crash" with
either the "data misalignment" or "access violation" errors.  When I run it
in release, everthing seems fine.  The other odd thing is that the place it
crashes in debug mode seems random.  Sometimes if I  execute a particular
line with
"F10", it will throw the exception.  The next time, if I hit "F5" past the
same line, or "F11" and step through it won't crash at all, or it will crash
in a different place.  If I change a piece of source code, recompile, and
run again, it will crash in a
different spot.  It seems like the executable file or maybe a library that I
am linking in is corrupt or misaligned when generating a debug build.  Is
this possible?  Has anyone seen anything similar?  Thanks.

Timothy Dean
MobileDataforce
0
kevinbenedict
Asked:
kevinbenedict
2 Solutions
 
mactep13Commented:
Check your struct member allignment. Is it set to default (8 Bytes)?

Also, check for any #pragma's in your code.
Something like
#pragma pack 1
or whatever?
If you have this, remember to call #pragma pack without any numbers to reset the allignment.
Check all of your libs that you're linking against. Make sure their allignment is set to 8 and that there are no packs.

I have seen this behaviour before if the #pragma pack was invoked without it being released.

Hope this helps,

mactep
0
 
DanRollinsCommented:
I agree with mactep13 and add generic advise:.
o  Carefully compare all of your build settings -- Release to Debug.
o  Do a complete clean and rebuild to eliminate some potential sources of problems.
o  Since it is intermittant, also look for external causes -- such as timeouts caused by
    network traffic, disk full errors, and so forth

One major *standard* difference between a Debug build and a Release build is that TRACE and ASSERTs are active in the former.  Also, in Debug builds, there is extra padding for the variables (it is often the removal of that padding that casue the opposite problem:  failures in Release build... I mention it for completeness only).

-- Dan


0
 
kevinbenedictAuthor Commented:
My alignment is set to 8, and since I am using 3rd party libraries, I don't know how to check their libraries.  I didn't find any #pragma pack statements.  One thing to note is that I am using eVC++ on a PocketPC and debugging directly on the device.  

Another thing I noticed at one point when calling a function with a
parameter passed by value.  The parameter is passed as a contant string (ex:
functionCall("SomeText")).  When looking at the constructor of the parameter
object that takes the string, an invalid pointer arrives at the copy
constructor.  Thats something I have no control over, right?  It is like the
string table is corrupt at that point.

I may try creating a new project with all new build settings to see if that works.  Thanks for the input.  Let me know if you have any other thoughts.

Tim
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now