#82 closed enhancement (fixed)
Make SEH work in OS/2 context
Reported by: | dmik | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 0.8.5 |
Component: | odin | Version: | 0.8.4 |
Severity: | medium | Keywords: | |
Cc: |
Description
The current implementation of SEH (__try/__except
) requires Odin to force the Win32 TIB switch mode in which the FS register points to the Win32 thread information block instead of the OS/2 one.
This mode is the default in Odin if it runs a Win32 binary as this is what the binary expects and needs. But in cases when we build Win32 apps from sources there is actually no sense in maintaining this FS context switch from OS/2 to Win32 and back. Even if the Win32 application not only uses __try/__except
but also accesses FS directly, it can always be tailored with #ifdef (we can access the Win32 TIB with GetThreadTEB() regardless of the real FS value).
Switching FS may even be dangerous in some cases and this especially relates to situations when Win32 code calls OS/2 code and vice versa: the called party may not expect a wrong context (if e.g. it does its own exception handling since this is what FS is used mostly for). In either case, maintaining the context switch is error-prone per se due its complexity (you may look at e.g. sehutil.s to see it).
Change History (6)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
In r21999, I made SEH whork in OS/2 context. This required quite a bit of changes.
Note that the new scheme is active by default (when ever you use __try/__except
). In order to use the old SEH scheme which causes FS switch (called now SEH in Win32 mode) ODIN_FORCE_WIN32_TIB should be defined for all compiled sources AND ForceWin32TIB() should be called in main() (just like EnableSEH() was called before; ForceWin32TIB() is actually a new name for this function, for clarity).
Note also that the behavior of binary Win32 applications is NOT affected by this change: since they always work in ForceWin32TIB()-like mode (causing FS switch), everything will remain the same for them.
comment:3 by , 13 years ago
Note that Odin still does the FS switch in some places not related to SEH even when ForceWin32TIB is not called(). This needs to be investigated as I suppose it may be removed as well. I created #83 for that.
comment:4 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Great, this really helped. The TCP/IP configuration application (http://svn.netlabs.org/java/ticket/162) now works fine.
One problematic case is described here: http://svn.netlabs.org/java/ticket/162#comment:6 and below.