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. WSAStartup generates unhandled exception

WSAStartup generates unhandled exception

Scheduled Pinned Locked Moved C / C++ / MFC
graphicshelpquestion
21 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.
  • D David Crow

    When the exception is thrown, what does the call stack look like?

    "Love people and use things, not love things and use people." - Unknown

    "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

    J Offline
    J Offline
    jimjim733
    wrote on last edited by
    #12

    here's a copy of the stack not sure what I am looking for??? Jim

    std::vector<UnitInfoStruct *,std::allocator<UnitInfoStruct *> >::size() line 114 + 15 bytes
    CAlinksRemoteControl::ScanForUnits() line 480 + 14 bytes
    CMultiVueDlg::OnInitDialog() line 130
    AfxDlgProc(HWND__ * 0x00240334, unsigned int 272, unsigned int 3081096, unsigned int 3081096) line 35 + 14 bytes
    USER32! 7e418734()
    USER32! 7e42413c()
    USER32! 7e423b30()
    USER32! 7e43e599()
    USER32! 7e418734()
    USER32! 7e418816()
    USER32! 7e42a013()
    USER32! 7e42a998()
    CWnd::DefWindowProcA(unsigned int 272, unsigned int 3081096, long 0) line 1000 + 32 bytes
    CWnd::Default() line 249
    CDialog::HandleInitDialog(unsigned int 3081096, unsigned int 3081096) line 624 + 8 bytes
    CWnd::OnWndMsg(unsigned int 272, unsigned int 3081096, long 0, long * 0x0012f800) line 1815 + 17 bytes
    CWnd::WindowProc(unsigned int 272, unsigned int 3081096, long 0) line 1585 + 30 bytes
    AfxCallWndProc(CWnd * 0x0012fc08 {CMultiVueDlg hWnd=???}, HWND__ * 0x00240334, unsigned int 272, unsigned int 3081096, long 0) line 215 + 26 bytes
    AfxWndProc(HWND__ * 0x00240334, unsigned int 272, unsigned int 3081096, long 0) line 368
    AfxWndProcBase(HWND__ * 0x00240334, unsigned int 272, unsigned int 3081096, long 0) line 220 + 21 bytes
    USER32! 7e418734()
    USER32! 7e418816()
    USER32! 7e42927b()
    USER32! 7e42651a()
    USER32! 7e42683e()
    USER32! 7e439b43()
    CWnd::CreateDlgIndirect(const DLGTEMPLATE * 0x0042b540, CWnd * 0x00000000 {CWnd hWnd=???}, HINSTANCE__ * 0x00400000) line 327 + 36 bytes
    CDialog::DoModal() line 531 + 32 bytes
    CMultiVueApp::InitInstance() line 71 + 11 bytes
    AfxWinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00151f0c, int 1) line 39 + 11 bytes
    WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00151f0c, int 1) line 30
    WinMainCRTStartup() line 330 + 54 bytes
    KERNEL32! 7c817067()

    D R 2 Replies Last reply
    0
    • J jimjim733

      here's a copy of the stack not sure what I am looking for??? Jim

      std::vector<UnitInfoStruct *,std::allocator<UnitInfoStruct *> >::size() line 114 + 15 bytes
      CAlinksRemoteControl::ScanForUnits() line 480 + 14 bytes
      CMultiVueDlg::OnInitDialog() line 130
      AfxDlgProc(HWND__ * 0x00240334, unsigned int 272, unsigned int 3081096, unsigned int 3081096) line 35 + 14 bytes
      USER32! 7e418734()
      USER32! 7e42413c()
      USER32! 7e423b30()
      USER32! 7e43e599()
      USER32! 7e418734()
      USER32! 7e418816()
      USER32! 7e42a013()
      USER32! 7e42a998()
      CWnd::DefWindowProcA(unsigned int 272, unsigned int 3081096, long 0) line 1000 + 32 bytes
      CWnd::Default() line 249
      CDialog::HandleInitDialog(unsigned int 3081096, unsigned int 3081096) line 624 + 8 bytes
      CWnd::OnWndMsg(unsigned int 272, unsigned int 3081096, long 0, long * 0x0012f800) line 1815 + 17 bytes
      CWnd::WindowProc(unsigned int 272, unsigned int 3081096, long 0) line 1585 + 30 bytes
      AfxCallWndProc(CWnd * 0x0012fc08 {CMultiVueDlg hWnd=???}, HWND__ * 0x00240334, unsigned int 272, unsigned int 3081096, long 0) line 215 + 26 bytes
      AfxWndProc(HWND__ * 0x00240334, unsigned int 272, unsigned int 3081096, long 0) line 368
      AfxWndProcBase(HWND__ * 0x00240334, unsigned int 272, unsigned int 3081096, long 0) line 220 + 21 bytes
      USER32! 7e418734()
      USER32! 7e418816()
      USER32! 7e42927b()
      USER32! 7e42651a()
      USER32! 7e42683e()
      USER32! 7e439b43()
      CWnd::CreateDlgIndirect(const DLGTEMPLATE * 0x0042b540, CWnd * 0x00000000 {CWnd hWnd=???}, HINSTANCE__ * 0x00400000) line 327 + 36 bytes
      CDialog::DoModal() line 531 + 32 bytes
      CMultiVueApp::InitInstance() line 71 + 11 bytes
      AfxWinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00151f0c, int 1) line 39 + 11 bytes
      WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00151f0c, int 1) line 30
      WinMainCRTStartup() line 330 + 54 bytes
      KERNEL32! 7c817067()

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

      jimjim733 wrote:

      not sure what I am looking for???

      It looks as though your code gets all the way into OnInitDialog() before the exception is thrown.

      "Love people and use things, not love things and use people." - Unknown

      "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

      1 Reply Last reply
      0
      • J jimjim733

        No, that didn't work :confused:

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #14

        What does "didn't work" mean? I didn't expect it to fix the exception - i only pointed out the fact that it was missing and wondered if there was a reason. Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        J 1 Reply Last reply
        0
        • J jimjim733

          here's a copy of the stack not sure what I am looking for??? Jim

          std::vector<UnitInfoStruct *,std::allocator<UnitInfoStruct *> >::size() line 114 + 15 bytes
          CAlinksRemoteControl::ScanForUnits() line 480 + 14 bytes
          CMultiVueDlg::OnInitDialog() line 130
          AfxDlgProc(HWND__ * 0x00240334, unsigned int 272, unsigned int 3081096, unsigned int 3081096) line 35 + 14 bytes
          USER32! 7e418734()
          USER32! 7e42413c()
          USER32! 7e423b30()
          USER32! 7e43e599()
          USER32! 7e418734()
          USER32! 7e418816()
          USER32! 7e42a013()
          USER32! 7e42a998()
          CWnd::DefWindowProcA(unsigned int 272, unsigned int 3081096, long 0) line 1000 + 32 bytes
          CWnd::Default() line 249
          CDialog::HandleInitDialog(unsigned int 3081096, unsigned int 3081096) line 624 + 8 bytes
          CWnd::OnWndMsg(unsigned int 272, unsigned int 3081096, long 0, long * 0x0012f800) line 1815 + 17 bytes
          CWnd::WindowProc(unsigned int 272, unsigned int 3081096, long 0) line 1585 + 30 bytes
          AfxCallWndProc(CWnd * 0x0012fc08 {CMultiVueDlg hWnd=???}, HWND__ * 0x00240334, unsigned int 272, unsigned int 3081096, long 0) line 215 + 26 bytes
          AfxWndProc(HWND__ * 0x00240334, unsigned int 272, unsigned int 3081096, long 0) line 368
          AfxWndProcBase(HWND__ * 0x00240334, unsigned int 272, unsigned int 3081096, long 0) line 220 + 21 bytes
          USER32! 7e418734()
          USER32! 7e418816()
          USER32! 7e42927b()
          USER32! 7e42651a()
          USER32! 7e42683e()
          USER32! 7e439b43()
          CWnd::CreateDlgIndirect(const DLGTEMPLATE * 0x0042b540, CWnd * 0x00000000 {CWnd hWnd=???}, HINSTANCE__ * 0x00400000) line 327 + 36 bytes
          CDialog::DoModal() line 531 + 32 bytes
          CMultiVueApp::InitInstance() line 71 + 11 bytes
          AfxWinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00151f0c, int 1) line 39 + 11 bytes
          WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00151f0c, int 1) line 30
          WinMainCRTStartup() line 330 + 54 bytes
          KERNEL32! 7c817067()

          R Offline
          R Offline
          Roger Stoltz
          wrote on last edited by
          #15

          Like David said, you seem to get as far as to OnInitDialog. Is it possible that the code using the vector doesn't run if the socket lib hasn't been initialized? That could explain why the error "goes away" if you omit the call to WSAStartup. To me it looks like the std::vector<UnitInfoStruct*> vector has not been created properly since vector::size() only operates on internal data and doesn't change anything. Could it be that the vector variable is a pointer that you haven't allocated memory for? :~ Just guessing, but it could be worth checking...

          "It's supposed to be hard, otherwise anybody could do it!" - selfquote
          "High speed never compensates for wrong direction!" - unknown

          J 1 Reply Last reply
          0
          • M Mark Salsbery

            What does "didn't work" mean? I didn't expect it to fix the exception - i only pointed out the fact that it was missing and wondered if there was a reason. Mark

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            J Offline
            J Offline
            jimjim733
            wrote on last edited by
            #16

            Sorry, just thought that might have fixed it. :(

            1 Reply Last reply
            0
            • R Roger Stoltz

              Like David said, you seem to get as far as to OnInitDialog. Is it possible that the code using the vector doesn't run if the socket lib hasn't been initialized? That could explain why the error "goes away" if you omit the call to WSAStartup. To me it looks like the std::vector<UnitInfoStruct*> vector has not been created properly since vector::size() only operates on internal data and doesn't change anything. Could it be that the vector variable is a pointer that you haven't allocated memory for? :~ Just guessing, but it could be worth checking...

              "It's supposed to be hard, otherwise anybody could do it!" - selfquote
              "High speed never compensates for wrong direction!" - unknown

              J Offline
              J Offline
              jimjim733
              wrote on last edited by
              #17

              Okay, thanks.....i'll take a look

              J 1 Reply Last reply
              0
              • J jimjim733

                Okay, thanks.....i'll take a look

                J Offline
                J Offline
                jimjim733
                wrote on last edited by
                #18

                okay, can you help? I am not sure how to do this:~ Below are the only references I have for UnitInfoStruct

                struct UnitInfoStruct *pUnit = NULL;

                	pUnit = new struct UnitInfoStruct;
                
                vector<struct UnitInfoStruct \*> m\_vszIPAddr;
                

                struct UnitInfoStruct {
                char szIPAddr[16];
                char szSer[9];
                };

                As you can tell, I am struggling with this a bit. Jim

                R 1 Reply Last reply
                0
                • J jimjim733

                  okay, can you help? I am not sure how to do this:~ Below are the only references I have for UnitInfoStruct

                  struct UnitInfoStruct *pUnit = NULL;

                  	pUnit = new struct UnitInfoStruct;
                  
                  vector<struct UnitInfoStruct \*> m\_vszIPAddr;
                  

                  struct UnitInfoStruct {
                  char szIPAddr[16];
                  char szSer[9];
                  };

                  As you can tell, I am struggling with this a bit. Jim

                  R Offline
                  R Offline
                  Roger Stoltz
                  wrote on last edited by
                  #19

                  Ok, it's the m_vszIPAddr variable I'm suspicious about, or rather its container since the variable itself is not a pointer. The reason why I think this is suspicious is you get an access violation, which usually means a pointer referencing out-of-bounds memory e.g. a very low address. Since you get the assertion inside the std::vector::size() function, which only operates on internal operators that doesn't reference memory outside the vector elements if initialized properly, my guess is that somehow the vector has not been initialized properly. As the vector itself is not a pointer, it should be initialized when its container is created and that's why I'm curious about the container. In your CAlinksRemoteControl::ScanForUnits() you must access the vector in some way, probably calling push_back() to add a new "unit". I would also like to see the code for allocating memory for a new "unit", how data is assigned to it and how it is inserted into the vector.

                  "It's supposed to be hard, otherwise anybody could do it!" - selfquote
                  "High speed never compensates for wrong direction!" - unknown

                  J 1 Reply Last reply
                  0
                  • R Roger Stoltz

                    Ok, it's the m_vszIPAddr variable I'm suspicious about, or rather its container since the variable itself is not a pointer. The reason why I think this is suspicious is you get an access violation, which usually means a pointer referencing out-of-bounds memory e.g. a very low address. Since you get the assertion inside the std::vector::size() function, which only operates on internal operators that doesn't reference memory outside the vector elements if initialized properly, my guess is that somehow the vector has not been initialized properly. As the vector itself is not a pointer, it should be initialized when its container is created and that's why I'm curious about the container. In your CAlinksRemoteControl::ScanForUnits() you must access the vector in some way, probably calling push_back() to add a new "unit". I would also like to see the code for allocating memory for a new "unit", how data is assigned to it and how it is inserted into the vector.

                    "It's supposed to be hard, otherwise anybody could do it!" - selfquote
                    "High speed never compensates for wrong direction!" - unknown

                    J Offline
                    J Offline
                    jimjim733
                    wrote on last edited by
                    #20

                    One thing I have tried is moving the WSAStartup to the main initDialog function and the app goes through. Any ideas???? jim:confused:

                    R 1 Reply Last reply
                    0
                    • J jimjim733

                      One thing I have tried is moving the WSAStartup to the main initDialog function and the app goes through. Any ideas???? jim:confused:

                      R Offline
                      R Offline
                      Roger Stoltz
                      wrote on last edited by
                      #21

                      jimjim733 wrote:

                      Any ideas?

                      Nope. I suggest you follow the call chain into ScanForUnits() from OnInitDialog() in debug mode. Verify that all objects operated on are created properly.

                      "It's supposed to be hard, otherwise anybody could do it!" - selfquote
                      "High speed never compensates for wrong direction!" - unknown

                      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