Article View: borland.public.cppbuilder.nativeapi
Article #7885SetExceptionMask is Dangerous?
From: Adam Guy
Date: Sun, 12 Dec 2004 18:57
Date: Sun, 12 Dec 2004 18:57
34 lines
2186 bytes
2186 bytes
Hi (posted previously in ActiveX group - not sure if it was the right
group - reposting here),
My COM server works well - but I found that some clients using it in C# had
bizarre problems which initially seemed unrelated.
After more investigation, I discovered that the .NET RTL expects all
exceptions to be masked. and that somehow when my component was created the
FPU exception mask was changed. I was able to reproduce this. I added a
routine to the end of my constructor and calls inside the COM server like
this:
SetExceptionMask(TFPUExceptionMask() << exInvalidOp
<< exDenormalized << exZeroDivide << exOverflow
<< exUnderflow << exPrecision);
And, now the C# code all works exactly like expected. (no problem). My
questions are:
1) Does this only set the exception mask for the current process? (I hope
so).
2) Is this going to screw up other clients? (non .NET) This makes me
nervous.
3) I tried getting the current control word in my constructor inside the COM
server with good intentions to try and restore it later, just before it
exited - but for some reason by the time my constructor is called - it is
already changed! I suspect that some mechanism inside the COM server
auto-generated code is changing it. Is there a better way for me to get,
change and the *restore* the control word from inside my COM server?
TIA.
M.
Technical Details
Message-ID:
<41bc94aa@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,8cde4124ca0c400e,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Adam Guy" <aguy@someco.de> Newsgroups: borland.public.cppbuilder.nativeapi Subject: SetExceptionMask is Dangerous? Date: Sun, 12 Dec 2004 10:57:56 -0800 Lines: 38 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 24.84.52.90 Message-ID: <41bc94aa@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1102877866 24.84.52.90 (12 Dec 2004 10:57:46 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail