none
How to handle access violation in strlen.asm while remote debugging ? RRS feed

  • Question

  • Firstly, I am very new to c++. Pardon my lack of knowledge.

    This is a work project. We're running VS 2005 to develop in one machine and Remote Debugger to Debug the application(.exe) in another machine (both of of the machine do not have any internet connections).  The application builds just fine but when debugged, it throws the error. Even if I put a breakpoint, the debugger doesn't go past the breakpoint no matter how many times I click continue. I've spent several days researching, and I came to know this kind of problem generally arises due to pointer pointing to null values or unsigned values. Now my problem is that I couldn't trace the error in a file that is written by Microsoft. Or maybe the error is not there and it is coming from another function that is using the file. 

    I couldn't post any image. The problem reads as: "Unhandled exception at:0x008874d0 in app.exe: 0xC000005: Access violation reading location 0x000001b0."

    Any small insight in this problem would help me do some more work on it.

    Thanks.


    • Edited by ribash1816 Thursday, September 19, 2019 3:09 PM
    Thursday, September 19, 2019 2:55 PM

All replies

  • Are you passing a null pointer or an invalid pointer to the strlen function?

    Set your breakpoint on the code that calls strlen and examine what is being passed to the function.

    Thursday, September 19, 2019 4:04 PM
  • tracing the error through breakpoint, the function strlen is called in another file "atlsimpstr.h" :

    static int __cdecl StringLength(__in_z_opt const char* psz) throw()
    {
      if(psz == NULL){
         return( 0 );
      }
      return (int(strlen(psz)));
    }

    Thursday, September 19, 2019 4:32 PM
  • tracing the error through breakpoint, the function strlen is called in another file "atlsimpstr.h" :

    static int __cdecl StringLength(__in_z_opt const char* psz) throw()
    {
      if(psz == NULL){
         return( 0 );
      }
      return (int(strlen(psz)));
    }

    So set a breakpoint there and examine the psz parameter that is being passed.  A null pointer shouldn't be the problem because the function checks for that and returns 0.

    When you find that psz is a bad pointer you should be able to examine the call stack to determine the source of the problem.

    • Edited by RLWA32 Thursday, September 19, 2019 4:40 PM
    Thursday, September 19, 2019 4:37 PM
  • Hi ribash1816,

    Welcome to MSDN forum.

    As your error, please have a try to allocate a new memory address to your pointer. Please refer here about it: Allocate a specific memory address using pointers in c++.

    Any feedback will be expected.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Friday, September 20, 2019 5:31 AM