Recent

Author Topic: [SOLVED] TEventLog.Info call caues Stack overflow in daemon app  (Read 404 times)

omurolmez

  • New Member
  • *
  • Posts: 10
Hello everyone,

If I build this code below with def FAIL, it adds "Recursion too deep; the stack overflowed." to Windows.Application log.

If I build it without def FAIL, it adds "Incorrect function."

Should I create a bug report or should I wait for someone else to try and approve bug to avoid creating unnecessary bug report ?

Lazarus 2.2.6 Fpc 3.2.2 Win 10 x64

--- Edit: SOLVED ----------------------------------------------------------------
There is no stack overflow.
Since the code does not supply a message file, Windows Event Log uses some default. So, event id 1001 comes across to that "Recursion too deep; the stack overflowed." message.
--- Edit: SOLVED ----------------------------------------------------------------

Code: Pascal  [Select][+][-]
  1. Program daemon_test;
  2. {$DEFINE FAIL}
  3.  
  4. Uses
  5.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  6.   CThreads,
  7.   {$ENDIF}{$ENDIF}
  8.   Classes, DaemonApp;
  9.  
  10. type
  11.   TDaemon1 = class(TCustomDaemon)
  12.   public
  13.     function Start: boolean; override;
  14.   end;
  15.  
  16. type
  17.   TDaemonMapper1 = class(TCustomDaemonMapper)
  18.   private
  19.   protected
  20.   public
  21.     constructor Create(AOwner :TComponent); override;
  22.   end;
  23.  
  24.   function TDaemon1.Start: boolean;
  25.   begin
  26.     {$IFDEF FAIL}
  27.     Logger.Info('TDaemon1.Start');
  28.     {$ELSE}
  29.     Logger.Log('TDaemon1.Start');
  30.     {$ENDIF}
  31.  
  32.         Result := True;
  33.   end;
  34.  
  35. constructor TDaemonMapper1.Create(AOwner :TComponent);
  36. begin
  37.   inherited Create(AOwner);
  38.   with TDaemonDef(self.DaemonDefs.Add) do
  39.   begin
  40.     DaemonClassName :='TDaemon1';
  41.     Name :='TestDaemon';
  42.     DisplayName :='Test Daemon';
  43.     Options := [doAllowStop];
  44.     WinBindings.StartType := stManual;
  45.     WinBindings.ServiceType := stWin32;
  46.   end;
  47. end;
  48.  
  49. begin
  50.   RegisterDaemonClass(TDaemon1);
  51.   RegisterDaemonMapper(TDaemonMapper1);
  52.  
  53.   Application.EventLog.Identification :='Daemon 1';
  54.  
  55.   Application.Run;
  56. end.

Regards
Ömür Ölmez.
« Last Edit: May 22, 2023, 06:25:54 pm by omurolmez »

 

TinyPortal © 2005-2018