Re: VB6 SP6 Issue with the Win32 Unhandled Exception Handler

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Mark Hurd (markhurd_at_ozemail.com.au)
Date: 04/22/04


Date: Thu, 22 Apr 2004 23:50:49 +0930



"Peter Huang" wrote:
> Hi Mark,
>
> I did not understand your meaning very well.

The purpose of this construct is to catch errors (Win32 exceptions) that the
VB runtime doesn't -- the exceptions that normally cause the Abnormal Program
Termination dialogue, which offers a stacktrace or to debug the process
depending on the O/S and settings. (I referred to it as GPF even though that
is really a Win3.1 concept.)

Also, I have now found the changed SP6 behaviour only happening with my full
project, not with a simple test, nor a form displaying each of the controls
the full project uses. The problem does not occur if the program's login form
fails to log on, so I can probably isolate the control or construct that is
causing the problem, but it will take a while. :-(

> > Now if you do happen to press the Stop button (absentmindedly or in
> > situations where edit and continue can't continue), unhandled
> > exceptions are rare enough that you may successfully run the code
> > again. I have some Asserts after (*) above to highlight I've
> > stuffed up and need to restart the IDE:
>
> What do you mean press the Stop button and when do you press the stop
> button?

Sorry, the correct term is the End button, and as I implied above I don't
intend using it.

Unlike subclassing scenarios, where not letting the VB code that undoes the
changes run almost always causes the IDE to crash after Ending the program,
unhandled Win32 exceptions are rare and you can often get away with corrupting
the IDE's expected handler.

> Can you state more detailed and post a simple demo to explain what do
> you mean?

Like I said above I'd prefer to have pointed to all the existing posts and
articles showing this concept has been around for quite a while.

Nevertheless, I have attached a module that does the basic catching of a Null
pointer exception. Obviously most real unhandled exceptions are messier, but
most of the time the VB code in the handler works even if it all goes bad
after that.

> > OK, with that background, the problem with SP6 is that the
> > PreviousExceptionFilter returned by the second run corresponds to
> > (AddressOf UnhandledExceptionFilter), which would suggest the
> > restore call (#) did not occur, but a break point confirms it does.
> What do you mean by " the second run"? which code do you run?

The 'high-level' description is:

Normal debugging scenario:
The IDE starts and sets an unhandled exception filter of its own.
I run my VB code (with full compile), which changes the filter, and stores the
original.
Normal interaction possibly with edit and continue sessions.
The code restores the original filter at the end of the program.
[The next time I run my VB code the same 'original' filter is recorded.]

Ended scenario:
The IDE has its own unhandled exception filter.
I run my VB code, which changes the filter, and stores the original.
During normal debugging, for whatever reason (eg. Edit and continue not
allowing me to continue -- such as editing Select Case statements -- or right
at the start I realise I've not configured something that means it's a waste
of time continuing) the code Ends.
[If an unhandled exception occurs in the IDE now, various nasty things happen,
but mostly VB just disappears very quickly with no error message or
confirmation.]
[The next time I run my VB code the 'original' filter is already the one my VB
code uses.]

In SP6, in the normal debugging scenario, the next time I run the code I see
the 'previous' filter is already the one my VB code uses, as if I Ended the
program like above.

> I think a more detailed steps and demo will help us to understand your
> meaning. I will appreciate your efforts.

Unfortunately, as I mentioned above, I've now found this is specific to the
SP6 IDE with my commercial project :-(

I'll try to pair down the project to something small that repeatably causes
the problem. (Or I could start VB in C++ and just put a value change
breakpoint on the UnhandledExceptionFilter value, if I can watch O/S
locations.)

> Best regards,
>
> Peter Huang
> Microsoft Online Partner Support

-- 
Regards,
Mark Hurd, B.Sc.(Ma.) (Hons.)
PS: I've taken a while to reply because I had trouble locating the VB6 code on
Usenet or the web that this concept is based upon. (This search caused me to
notice the VB2theMax VB6 archives are gone -- absolutely crazy :-( )
I posted a reply to this message:
http://groups.google.com.au/groups?selm=88sfda%24obg%241%40news.chorus.net
that included an early version the attached file on 14/3/2000, but Google
doesn't have my post. (It was around a time where I can see other posts in my
Sent Items where I've sent duplicates direct to Microsoft's news server
instead of the OE default news server, so perhaps no one's seen it before
:-( )




Relevant Pages

  • Re: cant detect dr.watson error
    ... > how to deal with exceptions is obviously a tricky question. ... > i'm not a lazy programmer. ... I would still recommend to install a custom filter using SetUnhandledExceptionFilter. ... Writing a minidump with MiniDumpWriteDump can also be useful there. ...
    (microsoft.public.vc.language)
  • Re: getting a stack trace from a c++ exception
    ... Getting a stack trace from Windows SEH exceptions using ... I believe Microsoft refers to these as "C" exceptions. ... context and make it available to the catch block or some filter. ...
    (microsoft.public.vc.language)
  • Re: getting a stack trace from a c++ exception
    ... > do what SEH does. ... Yes, unlike Java, native C++ does not preserve call stack information ... Since C++ exceptions are actually implemented ... and therefore get the context in the SEH filter. ...
    (microsoft.public.vc.language)
  • Re: Gracefully handling a crash
    ... > the fault to continue. ... You should get the address of the previously registered filter (returned ... call this filter after your own processing and return the value returned by it. ... Also do not allow your filter to raise any unhandled exceptions - wrap ...
    (microsoft.public.vc.debugger)
  • unhandled exception in unknown module
    ... In a VB .NET app, I am dynamically changing a form's menu. ... testing the code in the IDE, I got intermittent exceptions thrown: ... problem occurs only in the IDE - my stress tests run fine when I run the exe ...
    (microsoft.public.dotnet.general)