SUGGESTED FIX
Microsoft 64 bit Windows implementations no longer use frame based
exception processing for delivering it's Structured Exceptions.
C++ compilers instead must create function based data structures that
are incorporated in the .EXE and .DLL file format that Windows uses
to deliver its exceptions. Dynamically generated code can not use
this facility since the load address and range of the generated code
is not know at compile/link time.
To work around this problem, the VM uses VectoredExceptions in
1.4.2 and 1.5 VM's on IA64 and AMD64. VectoredExceptions are
similar to Unix signals. This mechanism works unless native code
wishes to use structured exceptions. In this situation, our
VectoredException handler takes control and the VM will generate
an error wince the exception was not generatred by any VM code.
A simple solution to this problem is to not allow native code to
use SEH. This would work except for the fact that the Windows
runtime libraries, use it to implement an accelerated malloc function.
We worked around this bug in 1.5 by detecting exceptions in the
NTDLL.DLL library but this leaves us open to other libraries
in the OS doing the same thing.
The real solution is to use an API new to Win64 that allows
dynamically generated code to register it's code with the OS
so Windows can determine which exception handler to call based
on the IP address at the time of the exception.
This mechanism is not very well documented and if implemented
fully, would require us to register our prologue, frame setup,
epilog and pseudo code to unwind stack frame for each method we
compile. One further compilcation is that the unwind data structures
are CPU dependent (IA64 and AMD64 are very different).
Rather than complicate the code in the VM and reduce and compile
time overhead, I decided to register all dynamically generated code
in the VM as a single function. The unwind structure registered
in the VM has no unwind code definitions and contains a single
entry specifying the exception handle for this code region.
NOTE THIS FIX IS AMD64 ONLY:
The IA64 unwind information data is different from AMD64.
I could not find any Microsoft documentation describing this.
I found a reference to Intel docs but they did not match up
with the MS docs. Since IA64 is currently not a planned release
for 1.6, I decided to make an AMD64 only fix. Future work will have
to be done to implement this bug fix for IA64.
###@###.### 11/3/04 16:54 GMT
|