0

I have a c++ application which does authentications.The scenario is like testing maximum number of authentications it can do in a time period like 15 mins.So while testing its performance on a quad core machine with a performance testing software called "Load Runner",I am facing an issue

I am getting lot of exceptions, I am catching them but the hard part is ,I can't find the type of that exception.So to simulate the Load runner behaviour I wrote a multithreaded program and did authentications in parallel,this time inorder to find where the exception is coming I removed the generic catch block and let the application crash and I also configured windbg as postmortem debugger.So the application crashed and in the stack trace i found it is crashing in "xerces" dll(an xml parser i used). So now i know the type of exception and I tried to catch these exceptions by using these catch blocks

    catch (const XMLException& toCatch)
    {
        char* message = XMLString::transcode(toCatch.getMessage());
        cout << "xerces exception :" << message;           
        XMLString::release(&message);
        return -1;
    }
    catch (const DOMException& toCatch) 
    {
        char* message = XMLString::transcode(toCatch.msg);
        cout <<"xerces DOMexception :" << message; 
        XMLString::release(&message);
        return -1;
    }

but still it was going to the generic catch block,I tried "bad_alloc" also(just to give it a try), it didnt catch it too.

I followed the recommendations given by xerces for thread safety. But still Im getting these exceptions. What is puzzling me is what on earth is the type of that exception? Does that even has a type at all?

EDIT:I can see my application crashing in xerces dll,since it is a thirdparty dll i dont know what i can do to fix it. Windbg reports like this after each time it crashes

FAULTING_IP: 
xerces_c_3_1_vc80!xercesc_3_1::DOMImplementationRegistry::getDOMImplementation+31
120e2681 8b30            mov     esi,dword ptr [eax]

EXCEPTION_RECORD:  ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 120e2681       (xerces_c_3_1_vc80!xercesc_3_1::DOMImplementationRegistry::getDOMImplementation+0x00000031)
   ExceptionCode: c0000005 (Access violation)
  ExceptionFlags: 00000000
NumberParameters: 2
   Parameter[0]: 00000000
   Parameter[1]: 00000000
Attempt to read from address 00000000

What Can I do in this case?What do you guys recommend?

  • `So the application crashed and in the stack trace i found it is crashing in "xerces" dll(an xml parser i used). So now i know the type of exception ` That doesn't tell you the type of exception. All you know is that some instruction in that DLL caused a crash. If that crash is a Structured Exception (SE), i.e. access violation or some OS generated exception, then try / catch will not help unless the DLL and your application is built with SEH exception handling turned on. – PaulMcKenzie Mar 21 '14 at 18:46
  • To elaborate, in C++ you can throw anything. Literally. Wanna through a std::string? sure. Wanna throw an int? No problem. Want to throw an std::exception? go ahead. (There are alot of guidelines that say what you SHOULDN'T do, but nothing to limit you). IMHO this has made C++ exceptions largely useless as it causes the problems you are having. Turn on SEH exception handling, make sure its enabled in you windbg. Another trick I use is by stepping through the code you can often find which call is the problem, which can help you debug regardless of if you know the exception. – IdeaHat Mar 21 '14 at 18:56
  • (I should clarify, you can also throw nothing, `in main(){throw;}` is one of the fastest ways to get your code to crash) – IdeaHat Mar 21 '14 at 19:08
  • http://stackoverflow.com/questions/2443135/how-do-i-find-where-an-exception-was-thrown-in-c is an interesting read – IdeaHat Mar 21 '14 at 19:09
  • There are other exceptions which xerces library can throw refer http://xerces.apache.org/xerces-c/apiDocs-3/hierarchy.html – Ravi Mar 21 '14 at 19:13
  • @Anul Prakash - The exception is an access violation (0xc00000005). A C++ exception will not catch these unless you have a structured exception handling turned on (SEH handling) when you built your application. But the issue is that you know what the exception is, so how do you fix it? That is a different thing altogether. From the looks of it, the xerces code is attempting to dereference a NULL pointer. – PaulMcKenzie Mar 21 '14 at 19:23

1 Answers1

0

The exception you posted seems to be an access violation (0xc00000005). A C++ exception will not catch these unless you have structured exception handling turned on (SEH) when you built your application.

But the other issue is that you know what the exception is, so how do you fix it? That is a different thing altogether. From the looks of it, the xerces code is attempting to dereference a NULL pointer.

You should have handy a debuggable version of the xerces library (which comes with full source code), and attempt to duplicate the crash using that version. Then at least you can see exactly what is happening at the crash location and how it occurred.

PaulMcKenzie
  • 34,698
  • 4
  • 24
  • 45