Exception Handling with a "bad" ESP

Alexandre Julliard julliard at winehq.org
Sat Jul 23 03:22:09 CDT 2005


Glenn Wurster <gwurster at scs.carleton.ca> writes:

> GDI is a very good example of the problem of throwing an exception
> where the application never intended one to be thrown.  If ESP is bad
> we clobber something.  GDI, however, is not the only example.  If we
> fix it so that GDI does not throw exceptions, then we have to fix it
> so that we only throw exceptions when windows throws exceptions.
> Nothing more, nothing less - otherwise we have the issue of
> potentially having a bad ESP and clobbering something.  The issue of
> never throwing an exception unless Windows would have is a larger
> problem and involves more than just GDI code.  We can't enforce ESP
> usage on windows programs, so we have to come to terms with the fact
> that they may not use the ESP register as we would like.

Sure, but that's a very rare case, since messing with ESP means you
can't debug the code on Windows either. It would of course be possible
to use a separate stack for exceptions, in fact we used to do that,
but it has other problems and it's not how Windows does it.

So yes, the general rule is to avoid having exceptions where Windows
doesn't. Things like DOS memory could be fixed if we found an app that
really breaks because of that, but until we do I wouldn't worry too
much about it.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list