You are not logged in.
Pages: 1
implementation
{$R *.lfm}
var
aModel: TOrmModel;
aServer: TRestServerDB;
aApplication: TBlogApplication;
aHTTPServer: TRestHttpServer;
aHTTPServer443: TRestHttpServer;
LogFamily: TSynLogFamily;
procedure TForm1.Button1Click(Sender: TObject);
begin
aModel := CreateModel;
aServer := TRestServerDB.Create(
aModel, ChangeFileExt(Executable.ProgramFileName, '.db'));
aServer.DB.Synchronous := smNormal;
aServer.DB.LockingMode := lmExclusive;
aServer.Server.CreateMissingTables;
aApplication := TBlogApplication.Create;
aApplication.Start(aServer);
aHTTPServer443 := TRestHttpServer.Create([aServer], '443', 32, secTLS, HTTPSERVER_DEBUG_OPTIONS,
'C:\Users\aaa\Desktop\ssl\mycert.pfx',
'C:\Users\aaa\Desktop\ssl\privkey.pem',
'|sBcaVv;"f',
'C:\Users\aaa\Desktop\ssl\cert.pem');
aHTTPServer443.RootRedirectToURI('blog/default');
aServer.RootRedirectGet := 'blog/default';
aHTTPServer := TRestHttpServer.Create('8092', aServer, '+',
HTTP_DEFAULT_MODE, nil, 16, secNone, '', '', HTTPSERVER_DEBUG_OPTIONS);
aHTTPServer.RootRedirectToURI('blog/default'); // redirect / to blog/default
//aHTTPServer.RootRedirectToURI('blog/default', True, True);
aServer.RootRedirectGet := 'blog/default'; // redirect blog to blog/default
end;
Convert the mvc-blog example into a program with a form, without making any other changes. Start the program, then open the web page, and then exit the program. At this point, the following error message will appear: "Access violation writing to address $0000000000000024."
I am using Lazarus 3.0.
Of course, you need to access it via https. https://localhost/blog/default
Last edited by testgary (2025-06-21 19:38:16)
Offline
I can't reproduce it - it work as expected at least on fpc 3.2.2.
edit: ... and mormot 2.3.10775
For testing, I downloaded the latest Lazarus 4.0 RC + mORMot ('2.3.11235'), but I still reproduced the error. I'm not sure if it's my issue or if the code itself is designed that way — it seems necessary to explicitly add the freeing code on exit.
I added the freeing code at the end before exiting, and then the problem did not occur.
Steps to reproduce the error:
Create a new form application, call the units from the mvc-blog example and other necessary units
Run the form application and start it
Open https://localhost/blog/default
Close the form
An error dialog pops up, reproducing the error.
uses
MVCModel, MVCViewModel;
var
Form1: TForm1;
aModel: TOrmModel;
aServer: TRestServerDB;
aApplication: TBlogApplication;
aHTTPServer, aHTTPSServer: TRestHttpServer;
LogFamily: TSynLogFamily;
implementation
{$R *.lfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
aModel := CreateModel;
aServer := TRestServerDB.Create(aModel, ChangeFileExt(Executable.ProgramFileName, '.db'));
aServer.DB.Synchronous := smNormal;
aServer.DB.LockingMode := lmExclusive;
aServer.Server.CreateMissingTables;
aApplication := TBlogApplication.Create;
aApplication.Start(aServer);
aHTTPServer := TRestHttpServer.Create('8092', aServer, '+', HTTP_DEFAULT_MODE, nil, 16, secNone, '', '', HTTPSERVER_DEBUG_OPTIONS);
aHTTPSServer := TRestHttpServer.Create([aServer], '443', 32, secTLS, HTTPSERVER_DEBUG_OPTIONS,
'C:\Users\ssl\mycert.pfx',
'C:\Users\ssl\privkey.pem',
'|&SSSv;"f',
'C:\Users\ssl\cert.pem');
aHTTPSServer.RootRedirectToURI('blog/default');
aServer.RootRedirectGet := 'blog/default';
aHTTPServer.RootRedirectToURI('blog/default'); // redirect / to blog/default
aServer.RootRedirectGet := 'blog/default'; // redirect blog to blog/default
end;
procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
aHTTPServer.Free;
aHTTPSServer.Free;
aApplication.Free;
aServer.Free;
end;
Offline
replace aHTTPSServer.RootRedirectToURI('blog/default'); // redirect / to blog/default
to aHTTPSServer.RootRedirectToURI('blog/default',true,true); // redirect / to blog/default
Last edited by Alek (2025-06-23 04:49:04)
Offline
unit mormot.core.log;
procedure InitThreadNumber(nfo: PSynLogThreadInfo);
GlobalThreadLock.Lock; // It seems that the problem lies with this method.
windows11 lazarus 4.0RC
Last edited by testgary (2025-06-23 07:23:35)
Offline
As I wrote: what is the stack trace?
My guess is that the UI layer is calling the TSynLog code after the mormot.core.log unit is finalized.
It may be a problem with the LCL code within Lazarus 4.0 RC.
Please try with https://github.com/synopse/mORMot2/commit/84d5e3560
Online
#0 ntdll:RtlInitializeResource+1251 at :0
#1 ntdll:RtlRaiseStatus+1167 at :0
#2 ntdll:RtlEnterCriticalSection+242 at :0
#3 InitThreadNumber(PSynLogThreadInfo($000000000A7EFFD8)) at mormot.core.log.pas:4628
#4 TSynLog.LockAndDisableExceptions(Failed to read data from register) at mormot.core.log.pas:4716
#5 TSynLog.LogInternalFmt(TSynLog($00000000014DCB40), sllTrace, $000000010057AAF8^: 'UnSubscribe(socket=% seq=%) cnt=% %', PVarRec($000000000A307A98), 4, TObject($00000000014E6930)) at mormot.core.log.pas:5782
#6 TSynLog.DoLog(Internal dereference error, Failed to read data from register, Internal dereference error, Failed to read data from register (while calculating location), Failed to read data from register, Failed to read data from register) at mormot.core.log.pas:5261
#7 TWinIocp.Unsubscribe(Failed to read data from register, Internal dereference error) at mormot.net.sock.windows.inc:1947
#8 TPollAsyncSockets.Stop(TPollAsyncSockets($00000000015075B0), TPollAsyncConnection($000000000AB193B0), 'Fatal Error') at mormot.net.async.pas:1751
#9 TPollAsyncSockets.CloseConnection(TPollAsyncSockets($00000000015075B0), nil, 'Fatal Error') at mormot.net.async.pas:2010
windows11 lazarus 4.0
Offline
Pages: 1