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. Unhandled exception at..... Access violation

Unhandled exception at..... Access violation

Scheduled Pinned Locked Moved C / C++ / MFC
data-structureshelpquestion
9 Posts 5 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.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    Hi, I have a Window app from which I am doing communication to a DOS app via named pipes My method of doing this is to signal a event after I have queued the messages to the DOS app The method from which I am signaling the event is inoked via SendWindow and has and thus has a prototype LRESULT (WPARAM, LPARAM) The problem is as soon as I SIGNAL the event control is transfered When control is returned to the method which signaled the event it executes the next statement which causes an access violation listed below is the code in question

    LRESULT CprogDebug::receive_tcpip(WPARAM mywparam,LPARAM mylparam)

    .
    .
    .
    .
    .
    
    
        myeventptr->send\_window = this;
       myeventptr->SetEvent();              // queue message
        return TRUE;   // <==== access violation 
    

    Thanks in Advance

    C 1 Reply Last reply
    0
    • F ForNow

      Hi, I have a Window app from which I am doing communication to a DOS app via named pipes My method of doing this is to signal a event after I have queued the messages to the DOS app The method from which I am signaling the event is inoked via SendWindow and has and thus has a prototype LRESULT (WPARAM, LPARAM) The problem is as soon as I SIGNAL the event control is transfered When control is returned to the method which signaled the event it executes the next statement which causes an access violation listed below is the code in question

      LRESULT CprogDebug::receive_tcpip(WPARAM mywparam,LPARAM mylparam)

      .
      .
      .
      .
      .
      
      
          myeventptr->send\_window = this;
         myeventptr->SetEvent();              // queue message
          return TRUE;   // <==== access violation 
      

      Thanks in Advance

      C Offline
      C Offline
      charlieg
      wrote on last edited by
      #2

      Any time I see this on return, I think stack corruption.

      Charlie Gilley You're going to tell me what I want to know, or I'm going to beat you to death in your own house. "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

      F 1 Reply Last reply
      0
      • C charlieg

        Any time I see this on return, I think stack corruption.

        Charlie Gilley You're going to tell me what I want to know, or I'm going to beat you to death in your own house. "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

        F Offline
        F Offline
        ForNow
        wrote on last edited by
        #3

        Does that mean I should increase the stack size

        C L D 3 Replies Last reply
        0
        • F ForNow

          Does that mean I should increase the stack size

          C Offline
          C Offline
          charlieg
          wrote on last edited by
          #4

          Not necessarily, although that could be a reason. Does it declare the access violation when you reach the return statement or when you step through the return?

          Charlie Gilley You're going to tell me what I want to know, or I'm going to beat you to death in your own house. "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

          T 1 Reply Last reply
          0
          • F ForNow

            Does that mean I should increase the stack size

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            in my experience it often indicates a calling convention mismatch, e.g. a stdcall/cdecl mixup. :)

            Luc Pattyn [My Articles] Nil Volentibus Arduum

            1 Reply Last reply
            0
            • F ForNow

              Does that mean I should increase the stack size

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              Only if you need to, otherwise you'd just be masking the problem.

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

              F 1 Reply Last reply
              0
              • C charlieg

                Not necessarily, although that could be a reason. Does it declare the access violation when you reach the return statement or when you step through the return?

                Charlie Gilley You're going to tell me what I want to know, or I'm going to beat you to death in your own house. "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

                T Offline
                T Offline
                TomasRiker2
                wrote on last edited by
                #7

                Try to strip down your function to an absolute minimum and see if it still happens.

                Visit my project: Derivative Calculator

                1 Reply Last reply
                0
                • D David Crow

                  Only if you need to, otherwise you'd just be masking the problem.

                  "One man's wage rise is another man's price increase." - Harold Wilson

                  "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                  "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                  F Offline
                  F Offline
                  ForNow
                  wrote on last edited by
                  #8

                  Okay I think Luc Patyn is right I use LPARAM myparam as char * the string points to string returned by TCP/IP from the server machine Thanks

                  F 1 Reply Last reply
                  0
                  • F ForNow

                    Okay I think Luc Patyn is right I use LPARAM myparam as char * the string points to string returned by TCP/IP from the server machine Thanks

                    F Offline
                    F Offline
                    ForNow
                    wrote on last edited by
                    #9

                    thank you for all those who pointed me to the stack that is indeed were the problem was I had declared a CString as local/stack variable and and it was a long string I moved it outside of the function global and okay two question come to mind 1) how would I increase the stack if I needed it 2) using the new operator on the CString would seem to also alivate the problem as that would allocate the string on the heap thanks again

                    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