AV when accessing UserSession

delphi package - automated exception handling

Re: AV when accessing UserSession

Postby ZSL » Tue Dec 05, 2017 6:34 pm

..... update please
ZSL
 
Posts: 50
Joined: Thu Mar 31, 2016 11:23 pm

Re: AV when accessing UserSession

Postby madshi » Tue Dec 05, 2017 6:35 pm

Still working on madCodeHook <sigh>. But should get to this soon.
madshi
Site Admin
 
Posts: 9664
Joined: Sun Mar 21, 2004 5:25 pm

Re: AV when accessing UserSession

Postby ZSL » Tue Dec 12, 2017 6:08 pm

This is now 6 weeks.....

Will it ever be fixed?
ZSL
 
Posts: 50
Joined: Thu Mar 31, 2016 11:23 pm

Re: AV when accessing UserSession

Postby madshi » Tue Dec 12, 2017 6:17 pm

It's been unlucky timing, me busy with urgent madCodeHook support requests.

Anyway, your issue is almost at the top of my list now, I might actually get to it tomorrow.
madshi
Site Admin
 
Posts: 9664
Joined: Sun Mar 21, 2004 5:25 pm

Re: AV when accessing UserSession

Postby madshi » Wed Dec 13, 2017 3:49 pm

Ok, the solution is pretty simple:

1) Copy madIWSupport.pas/dfm and mad.inc into your project folder, and remove the write protection flag.
2) Comment out the line "handled := AApplication <> nil".

Done. It seems that in earlier IW versions the last parameter to "TIWServerControllerBase.DoException" was "var handled: boolean". And now in the latest version instead it seems to be something like "httpRequest: THttpRequest".

If the IW guys want to offer an official exception callback, basically all I need is a way to hook/overwrite TIWServerControllerBase.DoException. You can send them madIWSupport.pas, that should make it pretty easy for them to see what they could to help me get rid of the nasty hack. Or just send them the whole test project you attached to this thread here, together with madIWSupport.pas/dfm + mad.inc. Then they can test it all with the madExcept non-commercial edition. They could then just send me an updated madIWSupport.pas/dfm file which would work with their new exception callback logic.
madshi
Site Admin
 
Posts: 9664
Joined: Sun Mar 21, 2004 5:25 pm

Re: AV when accessing UserSession

Postby ZSL » Thu Dec 14, 2017 12:53 am

Sorry but this did not fix it.

I completed the tasks you advised. Did a rebuild. Did not fix it.

I deleted all madIWSupport.dcu on my system.

Renamed all madIWSupport.pas/dfm exceptthe one in my project dir.

Did a rebuild. Still did not fix it.
ZSL
 
Posts: 50
Joined: Thu Mar 31, 2016 11:23 pm

Re: AV when accessing UserSession

Postby madshi » Thu Dec 14, 2017 1:00 am

Can you set a breakpoint in madIWSupport.pas. Does it reach the line before the commented out line?

(Not sure what to say, it definitely fixed it for me.)
madshi
Site Admin
 
Posts: 9664
Joined: Sun Mar 21, 2004 5:25 pm

Re: AV when accessing UserSession

Postby ZSL » Thu Dec 14, 2017 5:22 pm

I did try but it did not get to the break point.
ZSL
 
Posts: 50
Joined: Thu Mar 31, 2016 11:23 pm

Re: AV when accessing UserSession

Postby madshi » Thu Dec 14, 2017 5:27 pm

Hmmmm... Do any breakpoints work at all in madIWSupport.pas? You may have to edit the options in mad.inc to make breakpoints work. It needs to be "{$D+}{$L+}".

FWIW, I've tested with Tokyo 10.2 and the latest IW version.
madshi
Site Admin
 
Posts: 9664
Joined: Sun Mar 21, 2004 5:25 pm

Re: AV when accessing UserSession

Postby ZSL » Thu Dec 14, 2017 11:43 pm

It was very early (my time) when I last responded.

I set "{$D+}{$L+}" to get breakpoints working...

At not time in my testing did I get an error at the line "// handled := AApplication <> nil;" when it is commented or not commented.

The problem occurs when accessing UserSession in the procedure AddCommandLineHeaderInfo. Evaluating UserSession returns "Access violation at 017086FF accessing 000000A4".

In the procedure AddCommandLineHeaderInfo UserSession is correctly exposed and I can accessed all variables and objects
ZSL
 
Posts: 50
Joined: Thu Mar 31, 2016 11:23 pm

Re: AV when accessing UserSession

Postby madshi » Fri Dec 15, 2017 11:49 am

Hmmmm... And this is with the test project you attached here? Or with your real project? To make sure we test the same thing: Which exact Delphi version are you using, and 32bit or 64bit compilation? And I assume you're using the latest IW version?
madshi
Site Admin
 
Posts: 9664
Joined: Sun Mar 21, 2004 5:25 pm

Re: AV when accessing UserSession

Postby ZSL » Fri Dec 15, 2017 7:06 pm

This is with a real project.
Delphi XE
Latest version of IW
ZSL
 
Posts: 50
Joined: Thu Mar 31, 2016 11:23 pm

Re: AV when accessing UserSession

Postby madshi » Fri Dec 15, 2017 7:19 pm

Could you please double check with the test project you attached to this thread? That's the best way to ensure we're testing the same thing. Thanks.
madshi
Site Admin
 
Posts: 9664
Joined: Sun Mar 21, 2004 5:25 pm

Re: AV when accessing UserSession

Postby ZSL » Sat Dec 16, 2017 1:53 am

Same with the app I sent you.

In the TIWServerControllerBaseDoExceptionCallbackNew function execution gets to "HandleException(etNormal, AException, nil, true, Esp, Ebp, nil, esIntraweb, AApplication, 0, @bugReport);" then traces into "AddCommandLineHeaderInfo".

When it gets to the the line "exceptIntf.BugReportHeader['User #'] := UserSession.gv_UID;" of "AddCommandLineHeaderInfo".

Never get to process the line " exceptIntf.BugReportHeader['Site ID'] := UserSession.gv_SID;"

Does not output "User #" line to bugreport.txt

Also, after processing "HandleException(etNormal, AException, nil, true, Esp, Ebp, nil, esIntraweb, AApplication, 0, @bugReport);" the variable bugReport is always empty
ZSL
 
Posts: 50
Joined: Thu Mar 31, 2016 11:23 pm

Re: AV when accessing UserSession

Postby madshi » Mon Dec 18, 2017 7:11 pm

Interestingly, I wasn't able to reproduce this in Delphi Tokyo 10.2, but I *am* able to reproduce it in Delphi XE. I'm not sure where the difference is coming from.

When the crash occurs, in your ServerController.pas it seems "WebApplication" is nil. So "WebApplication.Data" crashes, of course. So please change the function "UserSession" to:

Code: Select all
function UserSession: TIWUserSession;
begin
  if WebApplication <> nil then
    Result := TIWUserSession(WebApplication.Data)
  else
    Result := nil;
end;

Of course then in UserSessionInit.pas you also need to change the code like this:

Code: Select all
procedure AddCommandLineHeaderInfo(const exceptIntf: IMEException; var handled: boolean);
begin
  exceptIntf.BugReportHeader['Product'] := 'Test';
  if UserSession <> nil then
  begin
    exceptIntf.BugReportHeader['User #'] := UserSession.gv_UID;
    exceptIntf.BugReportHeader['Site ID'] := UserSession.gv_SID;
  end;
end;

I've no idea why WebApplication is nil in this situation. But I'm not an IntraWeb expert, so maybe you know.
madshi
Site Admin
 
Posts: 9664
Joined: Sun Mar 21, 2004 5:25 pm

PreviousNext

Return to madExcept

Who is online

Users browsing this forum: Google [Bot] and 2 guests