Strange Problems with Memory- and Object-Access
-
Hello! I have a major problem with my MFC-application: My software (MFC, VS2005) experiences since some minor changes some weird crashes. The stragest thing is, that most crashes are connected to one class, that keeps my configuration. But i don´t see anything, that might cause memory-leak or things like this. Here is what happens: - When assigning a config-object to another the programm crashes with "lock" I did a workaroung for this by transfering this object by reference, so there is only the "master-copy" of the object, that is only linked to the other objects using the data inside this object. - "Visual Leak Detector" delivers no memory-leak, but of course only if the app doesn´t crash - when accessing an funtion from an DLL (C-Code) i get a access-violation - an older (befor the changes) version is running perfectly - when compiling as "release" i get different crashes than with "debug" - when copying int-values from the config-object to an int i get 2^16-times the value (16bit left-shift of the value), e.g. 122 (1111010) becomes 7995392 (1111010 00000000 00000000) What i guess is, that there´s something wrong with memory-management inside my app. But i have no idea where it could be! Does anyone have any ideas how to find this problem? Thanks a lot for helping! J.
-
Hello! I have a major problem with my MFC-application: My software (MFC, VS2005) experiences since some minor changes some weird crashes. The stragest thing is, that most crashes are connected to one class, that keeps my configuration. But i don´t see anything, that might cause memory-leak or things like this. Here is what happens: - When assigning a config-object to another the programm crashes with "lock" I did a workaroung for this by transfering this object by reference, so there is only the "master-copy" of the object, that is only linked to the other objects using the data inside this object. - "Visual Leak Detector" delivers no memory-leak, but of course only if the app doesn´t crash - when accessing an funtion from an DLL (C-Code) i get a access-violation - an older (befor the changes) version is running perfectly - when compiling as "release" i get different crashes than with "debug" - when copying int-values from the config-object to an int i get 2^16-times the value (16bit left-shift of the value), e.g. 122 (1111010) becomes 7995392 (1111010 00000000 00000000) What i guess is, that there´s something wrong with memory-management inside my app. But i have no idea where it could be! Does anyone have any ideas how to find this problem? Thanks a lot for helping! J.
The first thing I would check is the arrays (such as char[]) (if you use arrays) for overflow. In my experience, a one byte overflow in an array doesn't cause runtime errors, but can lead to the problems you are describing. I don't know how experienced you are, but remeber that the 'real' length of a char array is the length och the characters plus one (the terminating '\0'-byte).
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
-
The first thing I would check is the arrays (such as char[]) (if you use arrays) for overflow. In my experience, a one byte overflow in an array doesn't cause runtime errors, but can lead to the problems you are describing. I don't know how experienced you are, but remeber that the 'real' length of a char array is the length och the characters plus one (the terminating '\0'-byte).
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
-
Ok. Did you try a "Rebuild All"? (Probably, but I must ask).
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson