Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Strange Problems with Memory- and Object-Access

Strange Problems with Memory- and Object-Access

Scheduled Pinned Locked Moved C / C++ / MFC
announcementc++debuggingperformancehelp
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    J Holzer
    wrote on last edited by
    #1

    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.

    K 1 Reply Last reply
    0
    • J J Holzer

      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.

      K Offline
      K Offline
      kakan
      wrote on last edited by
      #2

      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

      J 1 Reply Last reply
      0
      • K kakan

        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

        J Offline
        J Offline
        J Holzer
        wrote on last edited by
        #3

        I checked this already. But with no result...

        K 1 Reply Last reply
        0
        • J J Holzer

          I checked this already. But with no result...

          K Offline
          K Offline
          kakan
          wrote on last edited by
          #4

          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

          J 1 Reply Last reply
          0
          • K kakan

            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

            J Offline
            J Offline
            J Holzer
            wrote on last edited by
            #5

            Of course. Not only one *g*

            K 1 Reply Last reply
            0
            • J J Holzer

              Of course. Not only one *g*

              K Offline
              K Offline
              kakan
              wrote on last edited by
              #6

              Then I'm out of ideas, sorry.

              Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups