Recent

Author Topic: Linux daemon's AccessViolation  (Read 169 times)

auRazor

  • New Member
  • *
  • Posts: 17
Linux daemon's AccessViolation
« on: January 21, 2021, 05:36:27 am »
I converted a Delphi windows application to freepascal daemon to run on linux.

I am using the lazdaemonapp and daemonapp code

The app was throwing an AccessViolation error every time i would send a killall -SIGTERM command.

After many hours I went back to base and created a new application with no code in it apart from DaemonApplication, DaemonMapper and DaemonApp code ran it and get the access violation message in syslog and this on the command line

$ ../temp/daemonexample/project1 -r
Exception at 0000000000000000: EAccessViolation:
Access violation.

Has anyone else used the apps and had any issues?

FreePascal=3.0.4
Lazarus=2.0.6
OS=Ubuntu 20.10

This is basically all the code

Project
Code: Pascal  [Select][+][-]
  1. Program project1;
  2.  
  3. Uses
  4. {$IFDEF UNIX}{$IFDEF UseCThreads}
  5.   CThreads,
  6. {$ENDIF}{$ENDIF}
  7.   DaemonApp, lazdaemonapp, DaemonMapperUnit1, DaemonUnit1
  8.   { add your units here };
  9.  
  10. begin
  11.   Application.Initialize;
  12.   Application.Run;
  13. end.

Mapper
Code: Pascal  [Select][+][-]
  1. unit DaemonMapperUnit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, DaemonApp;
  9.  
  10. type
  11.  
  12.   { TDaemonMapper1 }
  13.  
  14.   TDaemonMapper1 = class(TDaemonMapper)
  15.     procedure DaemonMapper1Create(Sender: TObject);
  16.   private
  17.  
  18.   public
  19.  
  20.   end;
  21.  
  22. var
  23.   DaemonMapper1: TDaemonMapper1;
  24.  
  25. implementation
  26.  
  27. procedure RegisterMapper;
  28. begin
  29.   RegisterDaemonMapper(TDaemonMapper1)
  30. end;
  31.  
  32. {$R *.lfm}
  33.  
  34. { TDaemonMapper1 }
  35.  
  36. procedure TDaemonMapper1.DaemonMapper1Create(Sender: TObject);
  37. var
  38. D : TDaemonDef;
  39. begin
  40.   D:=DaemonDefs.Add as TDaemonDef;
  41.   D.DisplayName:='Test Service daemon';
  42.   D.Name:='TestServiceDaemon';
  43.   D.DaemonClassName:='TDaemon1';
  44. end;
  45.  
  46.  
  47. initialization
  48.   RegisterMapper;
  49. end.
  50.  
  51.  

App
Code: Pascal  [Select][+][-]
  1. unit DaemonUnit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, DaemonApp;
  9.  
  10. type
  11.   TDaemon1 = class(TDaemon)
  12.   private
  13.  
  14.   public
  15.  
  16.   end;
  17.  
  18. var
  19.   Daemon1: TDaemon1;
  20.  
  21. implementation
  22.  
  23. procedure RegisterDaemon;
  24. begin
  25.   RegisterDaemonClass(TDaemon1)
  26. end;
  27.  
  28. {$R *.lfm}
  29.  
  30.  
  31. initialization
  32.   RegisterDaemon;
  33. end.
  34.  
« Last Edit: January 21, 2021, 05:58:06 am by auRazor »

auRazor

  • New Member
  • *
  • Posts: 17
Re: Linux daemon's AccessViolation
« Reply #1 on: January 21, 2021, 05:58:42 am »
Wrong location moving to programming/Linux

 

TinyPortal © 2005-2018