#1 2022-03-08 10:59:57

augusto
Member
Registered: 2017-01-16
Posts: 3

mORMot 2 - Project05HttpDaemon 64bit Error

Hi All,

This is my first post. Thanks for the great Job! smile

I've found an issue when using  TSynDaemon in the latest mORMot2 release.
... looking at, Project Project05HttpDaemon in ...\ex\ThirdPartyDemos\martin-doyle\05-HttpDaemonORM\src as an example ...

I believe there is a bug in mORMot2 when building for 64bit and starting the project as a service.

.\Project05HttpDaemon.exe /install - OK

When starting the service, using windows services dialog, I'm getting  an error:
-----------------------------
Windows could not start the Project05HttpDaemon service on
Local Computer.

Error 1067: The process terminated unexpectedly.
-----------------------------

Log File :
...
20220308 10482210  ! info  SetThreadName 243c=Main
20220308 10482210  ! info  Daemon started, listening on port 11111
20220308 10482210  " EXCOS EAccessViolation (c0000005) [] at 41265f

Using :
Delphi 10.4 Update 2
Win 10 pro

(It is working fine when using 16 Dec 2021 release and/or 32bit in current release)

Any thoughts?

Last edited by augusto (2022-03-09 09:27:04)

Offline

#2 2022-03-08 14:05:09

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: mORMot 2 - Project05HttpDaemon 64bit Error

Could you get on which source code line the access violation occurs?
(enabling detailed map file in the project option)

Online

#3 2022-03-08 15:46:44

augusto
Member
Registered: 2017-01-16
Posts: 3

Re: mORMot 2 - Project05HttpDaemon 64bit Error

Thanks,

27158 in System.pas

while P[Result] <> #0 do

log file:

20220308 15395239  " EXCOS EAccessViolation (c0000005) [] at 41265f System.pas @PWCharLen (27158)

Offline

#4 2022-03-08 16:12:02

stuart
Member
Registered: 2022-03-08
Posts: 6

Re: mORMot 2 - Project05HttpDaemon 64bit Error

The problem seems to be the ServiceProc procedure in mormot.core.os.windows.inc:

procedure ServiceProc(ArgCount: cardinal; Args: PPChar); stdcall;
var
  i: PtrInt;
begin
  if not Assigned(ServiceSingle) then
    exit;
  SetLength(ServiceSingle.fArgsList, ArgCount - 1);
  for i := 0 to ArgCount - 2 do //<- problem here
  begin
    Inc(Args);
    ServiceSingle.fArgsList[i] := Args^;
  end;

Because i is a 64-bit int and ArgCount is a cardinal, if ArgCount is less than 2 then the for loop termination value wraps around to a very high number and causes it to try to process arguments that don't exist.

Offline

#5 2022-03-08 17:46:05

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: mORMot 2 - Project05HttpDaemon 64bit Error

Online

#6 2022-03-08 18:22:17

augusto
Member
Registered: 2017-01-16
Posts: 3

Re: mORMot 2 - Project05HttpDaemon 64bit Error

That's great!

Thanks

Offline

#7 2022-10-21 10:44:32

zakaria
Member
Registered: 2021-06-21
Posts: 26

Re: mORMot 2 - Project05HttpDaemon 64bit Error

Hi ab,
i get the same issue with 64bits (Windows), the service install but it stuck at starting... status not running..., but it works at 32bits(windows)
even with latest master branch source.
Thanks smile

mormot 2.0.4222
Windows 10 64Bit
Delphi 11.2

Last edited by zakaria (2022-10-21 10:47:48)

Offline

#8 2022-10-21 13:56:31

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: mORMot 2 - Project05HttpDaemon 64bit Error

Do you have any exception raised in this case?

Does https://github.com/synopse/mORMot2/commit/e7aae08b help ?

Online

#9 2022-10-21 16:59:55

zakaria
Member
Registered: 2021-06-21
Posts: 26

Re: mORMot 2 - Project05HttpDaemon 64bit Error

i updated the sources to  https://github.com/synopse/mORMot2/commit/e7aae08b
but it still stuck at starting.. status, not getting running... status.

Offline

#10 2022-10-21 20:29:56

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: mORMot 2 - Project05HttpDaemon 64bit Error

But try to debug the service and see if it actually started to run the Execute method.

Online

#11 2022-10-24 17:03:52

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Re: mORMot 2 - Project05HttpDaemon 64bit Error

I tried it the weekend and I noticed that it creates an exception when trying to create the service
mormot.core.windows.inc

function TServiceController.Start(const Args: array of PChar): boolean;
begin
  if length(Args) = 0 then
    result := StartService(fHandle, 0, nil)
  else
    result := StartService(fHandle, length(Args), @Args[0]);
end;

tried admin account, same problem

Last edited by dcoun (2022-10-24 17:05:20)

Offline

#12 2022-10-25 12:54:48

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: mORMot 2 - Project05HttpDaemon 64bit Error

Please try with https://github.com/synopse/mORMot2/commit/b6bca670

On my side, I don't have any problem on Win64.

If the problem persists on your side, please try to replace the main block of Project05HttpDaemon as

begin
  LogFamily := SQLite3Log.Family;
  LogFamily.Level := LOG_VERBOSE;
  LogFamily.PerThreadLog := ptIdentifiedInOnFile;
  LogFamily.EchoToConsole := LOG_VERBOSE;
  LogFamily.CustomFileName := IntToHex(GetTickCount64, 8);
  WindowsServiceLog := SQLite3Log.DoLog;

  SQLite3Log.Add.Log(sllInfo, 'Daemon exe run %', [paramstr(1)]);
  SampleDaemon := TSampleDaemon.Create(
    TSampleDaemonSettings, Executable.ProgramFilePath, '', '');
  try
    LogFamily.Level := LOG_VERBOSE;
    LogFamily.EchoToConsole := LOG_VERBOSE;
    SampleDaemon.CommandLine;
  finally
    SQLite3Log.Add.Log(sllInfo, 'Daemon exe leave');
  end;

It should create several log files, with verbose information.

Online

#13 2022-10-25 19:53:19

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Re: mORMot 2 - Project05HttpDaemon 64bit Error

Offline

#14 2022-10-26 07:02:40

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: mORMot 2 - Project05HttpDaemon 64bit Error

@dcoun
This is weird because I am not able to reproduce the problem here.
I will look into your logs in detail.

Edit: Please try with https://github.com/synopse/mORMot2/commit/6d71a0a4
Edit 2: I tried with Alexandria 11.1 on Win64 and I have no problem with Project05HttpDaemon.dpr source code.

Two questions:
1) I think the log of /start is missing in the gist.  Can you add it?
2) Did you make any other change to Project05HttpDaemon source ?

Online

#15 2022-10-26 07:58:39

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Re: mORMot 2 - Project05HttpDaemon 64bit Error

Clean from github, last commit + the code you requested above
Alexandria 11.2 patch1
Only added win64 target

https://gist.github.com/dkounal/63adc5a … 01c26c29a9

Last edited by dcoun (2022-10-26 08:00:10)

Offline

#16 2022-10-26 08:13:44

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: mORMot 2 - Project05HttpDaemon 64bit Error

Instead of net start Project05HttpDaemon
please try Project05HttpDaemon /start

(but net start works on my PC)

Online

#17 2022-10-26 08:55:27

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Re: mORMot 2 - Project05HttpDaemon 64bit Error

Offline

#18 2022-10-26 11:42:48

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: mORMot 2 - Project05HttpDaemon 64bit Error

I was able to reproduce the problem on some Windows 11 specific configuration, whereas in older Windows version, there was no issue.
There was a problem with a handle defined as 32-bit instead of THandle (=64-bit on Win64).

It should be fixed now with https://github.com/synopse/mORMot2/commit/66bbc6db
Sorry for the delay in fixing this.

Online

#19 2022-10-26 11:48:15

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Re: mORMot 2 - Project05HttpDaemon 64bit Error

Thank you @ab, it works now

Offline

#20 2022-10-26 12:27:47

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: mORMot 2 - Project05HttpDaemon 64bit Error

The problem was already existing on mORMot 1.
See https://synopse.info/fossil/info/7c53aeed8d

It is weird that it has not been reported before.

Online

#21 2022-10-26 13:45:51

zakaria
Member
Registered: 2021-06-21
Posts: 26

Re: mORMot 2 - Project05HttpDaemon 64bit Error

Hi ab, i tried the last commit and it Works as expected, Thanks smile

Offline

#22 2022-12-08 14:35:42

zakaria
Member
Registered: 2021-06-21
Posts: 26

Re: mORMot 2 - Project05HttpDaemon 64bit Error

Hi ab,
i have some issues when i installed a windows service, it give me this error when i try to start it

Error 1053 [ERROR_SERVICE_REQUEST_TIMEOUT] occured with [/start] (Start) on Service 'MySampleService'

mormot 2.4418,D11.2,  windows 64 bits

Thanks smile

Offline

#23 2022-12-08 21:09:50

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: mORMot 2 - Project05HttpDaemon 64bit Error

Is it a regression, or something which happens sometimes on some systems?

Online

#24 2022-12-09 07:57:30

zakaria
Member
Registered: 2021-06-21
Posts: 26

Re: mORMot 2 - Project05HttpDaemon 64bit Error

regressionly, the log file containt just one line<

09/12/2022 07:55:40.288	Last error	1	 mormot.core.os.TServiceController(028242b04f30) Start(MySampleService) failed "ERROR_SERVICE_REQUEST_TIMEOUT" (1053)  

Offline

Board footer

Powered by FluxBB