Linux daemon's AccessViolation lazarus / 32-Linux ---------------------------------------------------------------------- auRazor · 2021-01-21 05:00 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Program project1; Uses{$IFDEF UNIX}{$IFDEF UseCThreads}  CThreads,{$ENDIF}{$ENDIF}  DaemonApp, lazdaemonapp, DaemonMapperUnit1, DaemonUnit1  { add your units here }; begin  Application.Initialize;  Application.Run;end. Mapper Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit DaemonMapperUnit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, DaemonApp; type   { TDaemonMapper1 }   TDaemonMapper1 = class(TDaemonMapper)    procedure DaemonMapper1Create(Sender: TObject);  private   public   end; var  DaemonMapper1: TDaemonMapper1; implementation procedure RegisterMapper;begin  RegisterDaemonMapper(TDaemonMapper1)end; {$R *.lfm} { TDaemonMapper1 } procedure TDaemonMapper1.DaemonMapper1Create(Sender: TObject);varD : TDaemonDef;begin  D:=DaemonDefs.Add as TDaemonDef;  D.DisplayName:='Test Service daemon';  D.Name:='TestServiceDaemon';  D.DaemonClassName:='TDaemon1';end;  initialization  RegisterMapper;end.   App Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit DaemonUnit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, DaemonApp; type  TDaemon1 = class(TDaemon)  private   public   end; var  Daemon1: TDaemon1; implementation procedure RegisterDaemon;begin  RegisterDaemonClass(TDaemon1)end; {$R *.lfm}  initialization  RegisterDaemon;end. ---------------------------------------------------------------------- PierceNg · 2021-01-21 06:36 You didn't include any lfm file. I compiled from your sources (commenting out the lfm include statements) and got this when run: Exception at 000000000042A5E6: EStreamError: Failed to initialize component class "TDaemonMapper1": No streaming method available. I don't use lazdaemon myself. I have some dockerized microservices written in FPC. Running in Docker means I don't have to care about daemonization. ---------------------------------------------------------------------- auRazor · 2021-01-21 07:53 Quote from: PierceNg on January 21, 2021, 07:36:17 amYou didn't include any lfm file. I compiled from your sources (commenting out the lfm include statements) and got this when run: Exception at 000000000042A5E6: EStreamError: Failed to initialize component class "TDaemonMapper1": No streaming method available. I don't use lazdaemon myself. I have some dockerized microservices written in FPC. Running in Docker means I don't have to care about daemonization. How did you get that error Pierce? My debugger goes to the assembler window. I would love to dockerize but that is not an option right  now. Have an attached the project zipped up ---------------------------------------------------------------------- PierceNg · 2021-01-21 08:52 Quote from: auRazor on January 21, 2021, 08:53:18 amHow did you get that error Pierce? My debugger goes to the assembler window. I ran the program on the command line. Quote from: auRazor on January 21, 2021, 08:53:18 amHave an attached the project zipped up I can't get it to load cleanly. See attached. I selected 'cancel loading this component' and plowed on. The program compiles. Running it: ./project1 Usage: /tmp/project1 [command] Where command is one of the following:   -i --install   To install the program as a service   -u --uninstall To uninstall the service   -r --run       To run the service Oh, I am using Lazarus 2.0.10 with FPC 3.2.0, on Ubuntu 20.04. ---------------------------------------------------------------------- auRazor · 2021-01-21 09:37 You need to add the lazdaemon package and run the application with a -r /tmp/project1 -r ---------------------------------------------------------------------- PierceNg · 2021-01-21 12:16 Quote from: auRazor on January 21, 2021, 10:37:57 amYou need to add the lazdaemon package and run the application with a -r /tmp/project1 -r No access violation error in my case. /tmp% ./project1 -r ---------------------------------------------------------------------- auRazor · 2021-01-21 12:44 Quote from: PierceNg on January 21, 2021, 01:16:37 pmQuote from: auRazor on January 21, 2021, 10:37:57 amYou need to add the lazdaemon package and run the application with a -r /tmp/project1 -r No access violation error in my case. /tmp% ./project1 -r Not even in syslog? ---------------------------------------------------------------------- PierceNg · 2021-01-21 14:11 Quote from: auRazor on January 21, 2021, 01:44:51 pmNot even in syslog? The program didn't crash. It is just doing nothing.     PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                13236 pierce    20   0   14308   3292   3016 S   0.0   0.0   0:00.00 project1 ---------------------------------------------------------------------- auRazor · 2021-01-22 00:04 I upgrade to fpc 3.2 and lazarus 2.0.10 and the program compiled and run without the issue. So i went back to the original program and now have another issue compiling zeoslib. I was kind of thinking that maybe I just need to recompile the freepascal library as I have upgraded the OS since I installed it but anyway ---------------------------------------------------------------------- auRazor · 2021-01-22 03:16 So after upgrading to FPC 3.2 my UDP server was not binding to a socket properly, so I rolled back and it was working as expected but getting the access violation again. Can't win ---------------------------------------------------------------------- trev · 2021-01-22 05:52 As for the not working with FPC 3.2.0, did you check the FPC 3.2.0 - User changes which may break code and possibly also FPC 3.2.0 - New Features ?