VB.NET - Troubleshooting a StackOverflow Exception

Posted on 2008-11-17
Last Modified: 2012-05-05
How can I go about troubleshooting this exception?

It happens randomly, I'm running the IDE and app in the background and when it happens all I can see on the notice box is the StackOverflow Exception and the "ok" button... the rest of the box is black so I can't see any details, etc...

When this exception occurs how can I see what is causing it? I appears to highlight a function that is called (in light grey), but that function calls a variety of other subs & functions as well...
What is the best way to find out where this is happening exactly? (ApplicationEvents didn't log anything or add anything to the event viewer either)

I have no idea what could be causing this error :(

Hanging application TSN.exe, version, hang module hungapp, version, hang address 0x00000000.

Category: 101 Event ID: 1002
Question by:mcainc
    LVL 12

    Expert Comment

    Hello, mcainc,

    This sort of problem is sometimes a result of unterminated recursion.  Do any of your routines make recursive (or reentrant) calls?  If you can't pinpoint the problem by inspection, you may have to add some tracing lines to your code.  (It's slow and a bit old fashioned, but works.)



    Author Comment

    hey randy,

    my classes go kind of deep... call other classes, etc. it is an irc chat client (that allows for multiple connections) so there is a ton of stuff thats going on everywhere

    i tried to profile the application with ANTS on a machine here... and when i came back the machine was locked up

    this sucks, i wish there was a way to show me what function or object locked up

    i guess i will try to add a ton of tracing lines to the app & its classes to see which one was fired last

    would a try / catch be able to catch a stack overflow exception?
    LVL 12

    Accepted Solution

    Hi, mcainc,

    No, I think that try/catch can't handle this error.  I don't know the details, but the exception handling probably need some space on the stack in order to function.  I found some words in the following link that may be helpful in understanding this (and if you can work in C++ may even provde hope for catching the exception).

    The fact that the problem seems to be random makes it doubly difficult to track down.  If you could find a circumstance where the problem was reliably reproduced it would help quite a lot.

    You say that the application is very deep with multiple connections.  Is it possible that it actually requires more stack than what is available?


    Author Closing Comment

    turns out it was a 3rd party dll that was acting up due to some malformed files it loaded... glad thats over!

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This video discusses moving either the default database or any database to a new volume.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now