MadExcept in 64 bit ISAPI.DLL in IIS7 : Maybe a sandbox?

delphi package - automated exception handling
Post Reply
wpostma
Posts: 23
Joined: Fri Oct 12, 2012 4:09 pm

MadExcept in 64 bit ISAPI.DLL in IIS7 : Maybe a sandbox?

Post by wpostma »

I have an interesting problem. MadExcept works GREAT on my 32 bit ISAPI DLL that runs inside Windows web-server (IIS7).

However the same Delphi DLL when built as Win64 does not work.

Here is a sample bug report, showing ONLY A SINGLE LEVEL on the exception stack trace for the thread. Note that if I use a standalone executable server, with the same 64 bit code, madexcept works FINE. The problems occur ONLY when using an ISAPI DLL, and ONLY when it's a 64 bit ISAPI DLL.
The stack trace is ONLY ONE LINE, there is no "stack traceback" occuring. This exact same code generates a 15 or 16 level stack traceback on Win32 ISAPI dlls, and also works fine with the same code in a 64 bit executable. ONLY problem is on 64 bit ISAPI.DLL when run INSIDE IIS's worker process.

Code: Select all

date/time          : 2014-06-05, 16:37:50, 192ms
computer name      : WPOSTMA
user name          : IUSR
registered owner   : Ramsoft
operating system   : Windows NT New x64 build 9600
system language    : English
system up time     : 9 days 4 hours
program up time    : 2 minutes 2 seconds
processors         : 12x Intel(R) Xeon(R) CPU W3670 @ 3.20GHz
physical memory    : 2564/12286 MB (free/total)
free disk space    : (C:) 11.78 GB
display mode       : 1024x768, 32 bit
process id         : $29fc
allocated memory   : 111.47 MB
largest free block : 130731.98 GB
command line       : c:\windows\system32\inetsrv\w3wp.exe -ap "DefaultAppPool" -v "v4.0" -l "webengine4.dll" -a \\.\pipe\iisipm0461e28e-f61c-4fa9-8acf-39da29c2501f -h "C:\inetpub\temp\apppools\DefaultAppPool\DefaultAppPool.config" -w "" -m 0 -t 20 -ta 0
executable         : w3wp.exe
current module     : prisapi.dll
module date/time   : 2014-06-05 16:32
version            : 6.0.0.428
compiled with      : Delphi XE5
madExcept version  : 4.0.10
callstack crc      : $823c930d, $823c930d, $823c930d
exception number   : 1
exception class    : EServerDummyException
exception message  : Exception Within a RemObjects Method #1- This is a sample exception.

thread $1e48:
0194972b +7b prisapi.dll ServerInfoService_Impl 75 +2 TServerInfoService.GenerateServerException

main thread ($2710):
>> stack not accessible

thread $2c8c:
>> stack not accessible

thread $2a00:
>> stack not accessible

.... (About 100 more thread $##### ...... >> stack not accessible repetitions removed. )

Any ideas? I have a feeling ISAPI on IIS7, on Windows 8.1, in 64 bit windows, may have implemented some really harsh "memory sandboxing" or something.
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Re: MadExcept in 64 bit ISAPI.DLL in IIS7 : Maybe a sandbox?

Post by madshi »

Hi Warren,

hmmmm... It could be some sort of sandboxing. It could also be something else, like dynamic code generation without setting up the correct exception framework information for that. In x64, exception handling is done very differently compared to x86. Basically each exe/dll comes with exact information about which functions exist, where the function "prolog" and "epilog" is located, etc etc. All this information is used by x64 to find the right try..except block and also to produce callstacks. If someone creates dynamic code without telling Windows about it, this can break the stacktraces.

I'm not sure if there's anything we can do about this. Unfortunately ISAPI is a nightmare to debug for me. I usually lose a few nights sleep just to create a working environment for ISAPI DLLs. So it's not like I could just spend a few minutes to have a quick look at this... :?
wpostma
Posts: 23
Joined: Fri Oct 12, 2012 4:09 pm

Re: MadExcept in 64 bit ISAPI.DLL in IIS7 : Maybe a sandbox?

Post by wpostma »

Okay, just for reference, the exception stack trace above should have produced output like this, and only the FIRST line works, so I'm seeing
"02a3d831 +055 PRISAPI.DLL ServerInfoService_Impl 75 +2 TServerInfoService.GenerateServerException" and that's it.

Code: Select all

thread $c6c:
02a3d831 +055 PRISAPI.DLL  ServerInfoService_Impl   75   +2 TServerInfoService.GenerateServerException
02ca364d +091 PRISAPI.DLL  powerreader_invk       4610   +6 TServerInfoService_Invoker.Invoke_GenerateServerException
020f67dc +158 PRISAPI.DLL  uROServer               798  +17 TROInvoker.CustomHandleMessage
020f69e6 +00e PRISAPI.DLL  uROServer               837   +1 TROInvoker.HandleMessage
020f5ee3 +6c7 PRISAPI.DLL  uROServer               565 +114 MainProcessMessage
020f736d +059 PRISAPI.DLL  uROServer              1029   +2 TROMessageDispatcher.ProcessMessage
020f7be1 +111 PRISAPI.DLL  uROServer              1425  +25 TROServer.IntDispatchMessage
02817e6e +382 PRISAPI.DLL  uROBaseHTTPServer       199  +61 TROBaseHTTPServer.ProcessRequest
028199c2 +0da PRISAPI.DLL  uROWebBrokerServer      229  +12 TROWebBrokerServer.IntOnBeforeDispatch
021016c8 +01c PRISAPI.DLL  Web.HTTPApp                      TCustomWebDispatcher.DoBeforeDispatch
021017ee +052 PRISAPI.DLL  Web.HTTPApp                      TCustomWebDispatcher.DispatchAction
02101a6e +006 PRISAPI.DLL  Web.HTTPApp                      TCustomWebDispatcher.HandleRequest
0210388d +03d PRISAPI.DLL  Web.HTTPApp                      TDefaultWebAppServices.InvokeDispatcher
02103830 +000 PRISAPI.DLL  Web.HTTPApp                      TDefaultWebAppServices.HandleRequest
02105ac5 +19d PRISAPI.DLL  Web.WebReq                       TWebRequestHandler.HandleRequest
02810ab6 +05a PRISAPI.DLL  RSISapiApp              124   +8 TRSISAPIApplication.HttpExtensionProc
02810cd9 +045 PRISAPI.DLL  RSISapiApp              185  +11 HttpExtensionProc
028114e4 +054 PRISAPI.DLL  RSISAPIThreadPool       117  +13 WorkerFunction
01d6a55c +028 PRISAPI.DLL  System                   19   +0 ThreadWrapper
776f495b +00c KERNEL32.DLL                                  BaseThreadInitThunk
wpostma
Posts: 23
Joined: Fri Oct 12, 2012 4:09 pm

Re: MadExcept in 64 bit ISAPI.DLL in IIS7 : Maybe a sandbox?

Post by wpostma »

I can now report some good success with madExcept working FINE with IIS 7 on Windows 8.1 and Server 2012 R2, in 64 bit ISAPI.

Our problems were general low level corruption of the heap, or a completely invalid stack contents or stack pointer.
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Re: MadExcept in 64 bit ISAPI.DLL in IIS7 : Maybe a sandbox?

Post by madshi »

Good to hear it's working well for you now!
Post Reply