Page 2 of 5

Re: AV when accessing UserSession

Posted: Tue Dec 05, 2017 6:34 pm
by ZSL
..... update please

Re: AV when accessing UserSession

Posted: Tue Dec 05, 2017 6:35 pm
by madshi
Still working on madCodeHook <sigh>. But should get to this soon.

Re: AV when accessing UserSession

Posted: Tue Dec 12, 2017 6:08 pm
by ZSL
This is now 6 weeks.....

Will it ever be fixed?

Re: AV when accessing UserSession

Posted: Tue Dec 12, 2017 6:17 pm
by madshi
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.

Re: AV when accessing UserSession

Posted: Wed Dec 13, 2017 3:49 pm
by madshi
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.

Re: AV when accessing UserSession

Posted: Thu Dec 14, 2017 12:53 am
by ZSL
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.

Re: AV when accessing UserSession

Posted: Thu Dec 14, 2017 1:00 am
by madshi
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.)

Re: AV when accessing UserSession

Posted: Thu Dec 14, 2017 5:22 pm
by ZSL
I did try but it did not get to the break point.

Re: AV when accessing UserSession

Posted: Thu Dec 14, 2017 5:27 pm
by madshi
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.

Re: AV when accessing UserSession

Posted: Thu Dec 14, 2017 11:43 pm
by ZSL
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

Re: AV when accessing UserSession

Posted: Fri Dec 15, 2017 11:49 am
by madshi
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?

Re: AV when accessing UserSession

Posted: Fri Dec 15, 2017 7:06 pm
by ZSL
This is with a real project.
Delphi XE
Latest version of IW

Re: AV when accessing UserSession

Posted: Fri Dec 15, 2017 7:19 pm
by madshi
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.

Re: AV when accessing UserSession

Posted: Sat Dec 16, 2017 1:53 am
by ZSL
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

Re: AV when accessing UserSession

Posted: Mon Dec 18, 2017 7:11 pm
by madshi
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.