Recent

Author Topic: Lazarus Release 2.2.0  (Read 73818 times)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9864
  • Debugger - SynEdit - and more
    • wiki
Re: Lazarus Release 2.2.0
« Reply #45 on: January 10, 2022, 01:16:51 am »
unfortunately the debug do not allow me to step in the procedure (as I put a breakpoint Lazarus show it as unreachable)

Did you recompile the package with debug info? (dwarf)

dbannon

  • Hero Member
  • *****
  • Posts: 2793
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Lazarus Release 2.2.0
« Reply #46 on: January 10, 2022, 03:44:57 am »
Yes, I agree, first place I would look is at -

Code: Pascal  [Select][+][-]
  1.   if FInputLines_SHARED <> nil then FInputLines_SHARED.free;
  2. ....
  3.   if FLines_SHARED<> nil then FLines_SHARED.free;

Has FInputLines_SHARED or FLines_SHARED been freed but not set to nil ?  Free-ing something does not set it to nil. Speaking as someone who has done it lots of times !

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: Lazarus Release 2.2.0
« Reply #47 on: January 10, 2022, 04:05:47 am »
hello,
i have found a doscommand for Lazarus (changed the original DosCommand (Delphi) to Lazarus) here and in this version the destructor is :
Code: Pascal  [Select][+][-]
  1. destructor TDosCommand.Destroy;
  2. begin
  3.   if FThread <> nil then Stop;
  4.   if FTimer <> nil then FTimer.free;
  5.   FSync.Free;
  6.   FInputLines_SHARED.free;
  7.   FLines_SHARED.free;
  8.   inherited;
  9. end;
as you can see no test if nil on FSync,  FInputLines_SHARED, FLines_SHARED.

Friendy J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

duzenko

  • New Member
  • *
  • Posts: 41
Re: Lazarus Release 2.2.0
« Reply #48 on: January 10, 2022, 07:41:15 am »
Kudos to the unnamed hero, who brought us "Run to Cursor"

DragoRosso

  • New Member
  • *
  • Posts: 13
Re: Lazarus Release 2.2.0
« Reply #49 on: January 10, 2022, 09:48:09 am »
Removed (RXDBGRID compilation with Lazarus 2.2.0). New post: https://forum.lazarus.freepascal.org/index.php/topic,57815.0.html

Sorry for OT.
« Last Edit: January 10, 2022, 11:21:45 am by DragoRosso »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: Lazarus Release 2.2.0
« Reply #50 on: January 10, 2022, 10:34:23 am »
@DragoRosso, please start a new forum thread about your RX package issues.
This thread is about Lazarus Release.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: Lazarus Release 2.2.0
« Reply #51 on: January 10, 2022, 01:41:03 pm »
Hello,
I know,

I try to replicate with a minimum amount of code but it works.

I have a component inherited from TDOSComand that I found in www.torry.net.

My component just call inherited in the destroy. The destroy in TDOSComand is

Code: Pascal  [Select][+][-]
  1. destructor TDosCommand.Destroy;
  2. begin
  3.   if FThread <> nil then Stop;
  4.   if FTimer <> nil then FTimer.free;
  5.   if FSync <> nil then FSync.Free;
  6.   if FInputLines_SHARED <> nil then FInputLines_SHARED.free;
  7.   if FLines_SHARED<> nil then FLines_SHARED.free;
  8.   inherited;
  9. end;  
  10.  

unfortunately the debug do not allow me to step in the procedure (as I put a breakpoint Lazarus show it as unreachable)

it seems that it is the debugger on 2.2 version of lazarus that causes the problem  :

no problem with version 2.0.12  when exiting a doscommand test program.
no problem when exiting a doscommand test program without debug in 2.2 version of Lazarus.
Access violation when exiting a doscommand test program with debug in 2.2 version of Lazarus (see attachment).

Friendly, J.P

Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

nouzi

  • Sr. Member
  • ****
  • Posts: 297
Re: Lazarus Release 2.2.0
« Reply #52 on: January 10, 2022, 02:30:07 pm »
Thanks for all
My English is  bad
Lazarus last version free pascal last version
Lazarus trunk  free pascal trunk 
System : Linux mint  64bit  Windows 7 64bit

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: Lazarus Release 2.2.0
« Reply #53 on: January 10, 2022, 03:11:06 pm »
Hello,
I know,

I try to replicate with a minimum amount of code but it works.

I have a component inherited from TDOSComand that I found in www.torry.net.

My component just call inherited in the destroy. The destroy in TDOSComand is

Code: Pascal  [Select][+][-]
  1. destructor TDosCommand.Destroy;
  2. begin
  3.   if FThread <> nil then Stop;
  4.   if FTimer <> nil then FTimer.free;
  5.   if FSync <> nil then FSync.Free;
  6.   if FInputLines_SHARED <> nil then FInputLines_SHARED.free;
  7.   if FLines_SHARED<> nil then FLines_SHARED.free;
  8.   inherited;
  9. end;  
  10.  

unfortunately the debug do not allow me to step in the procedure (as I put a breakpoint Lazarus show it as unreachable)

it seems that it is the debugger on 2.2 version of lazarus that causes the problem  :

no problem with version 2.0.12  when exiting a doscommand test program.
no problem when exiting a doscommand test program without debug in 2.2 version of Lazarus.
Access violation when exiting a doscommand test program with debug in 2.2 version of Lazarus (see attachment).

Friendly, J.P

the access violation comes with the terminate of the FThread :
Code: Pascal  [Select][+][-]
  1. procedure TDosCommand.Stop;
  2. begin
  3.   if (FThread <> nil) then
  4.   begin
  5.     FThread.FreeOnTerminate := true;
  6.     FThread.Terminate; //terminate the process
  7.     FThread := nil;
  8.   end;
  9. end;    
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: Lazarus Release 2.2.0
« Reply #54 on: January 10, 2022, 03:23:56 pm »
Hello,
I know,

I try to replicate with a minimum amount of code but it works.

I have a component inherited from TDOSComand that I found in www.torry.net.

My component just call inherited in the destroy. The destroy in TDOSComand is

Code: Pascal  [Select][+][-]
  1. destructor TDosCommand.Destroy;
  2. begin
  3.   if FThread <> nil then Stop;
  4.   if FTimer <> nil then FTimer.free;
  5.   if FSync <> nil then FSync.Free;
  6.   if FInputLines_SHARED <> nil then FInputLines_SHARED.free;
  7.   if FLines_SHARED<> nil then FLines_SHARED.free;
  8.   inherited;
  9. end;  
  10.  

unfortunately the debug do not allow me to step in the procedure (as I put a breakpoint Lazarus show it as unreachable)

it seems that it is the debugger on 2.2 version of lazarus that causes the problem  :

no problem with version 2.0.12  when exiting a doscommand test program.
no problem when exiting a doscommand test program without debug in 2.2 version of Lazarus.
Access violation when exiting a doscommand test program with debug in 2.2 version of Lazarus (see attachment).

Friendly, J.P

the access violation comes with the terminate of the FThread :
Code: Pascal  [Select][+][-]
  1. procedure TDosCommand.Stop;
  2. begin
  3.   if (FThread <> nil) then
  4.   begin
  5.     FThread.FreeOnTerminate := true;
  6.     FThread.Terminate; //terminate the process
  7.     FThread := nil;
  8.   end;
  9. end;    

With this code no more problem :
Code: Pascal  [Select][+][-]
  1. procedure TDosCommand.Stop;
  2. begin
  3.   if (FThread <> nil) then
  4.   begin
  5.     FThread.FreeOnTerminate := true;
  6.     If not FThread.Finished then  FThread.Terminate; //terminate the process
  7.     FThread := nil;
  8.   end;
  9. end;
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 370
Re: Lazarus Release 2.2.0
« Reply #55 on: January 11, 2022, 09:32:52 am »
Many thanks for your hard work on Lazarus 2.2!

mischi

  • Full Member
  • ***
  • Posts: 170
Re: Lazarus Release 2.2.0
« Reply #56 on: January 11, 2022, 09:42:07 am »
I am happy to announce that the macports packages are also updated to Lazarus 2.2.0 and fpc 3.2.2, including arm.

MiSchi

Nicola Gorlandi

  • Full Member
  • ***
  • Posts: 132
Re: Lazarus Release 2.2.0
« Reply #57 on: January 12, 2022, 07:53:02 pm »
Many Thanks to all,

I appreciate.

The change below fix the issue

Code: Pascal  [Select][+][-]
  1. If not FThread.Finished then  FThread.Terminate; //terminate the process

In order to do it by my own, how do you debug this issue ? Are you using the log or what else ?


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9864
  • Debugger - SynEdit - and more
    • wiki
Re: Lazarus Release 2.2.0
« Reply #58 on: January 12, 2022, 08:22:03 pm »
With this code no more problem :
Code: Pascal  [Select][+][-]
  1. procedure TDosCommand.Stop;
  2. begin
  3.   if (FThread <> nil) then
  4.   begin
  5.     FThread.FreeOnTerminate := true;
  6.     If not FThread.Finished then  FThread.Terminate; //terminate the process
  7.     FThread := nil;
  8.   end;
  9. end;

Actually: "No problem that you have spotted yet.

The code has a race condition. So there is a problem.

Code: Pascal  [Select][+][-]
  1.     FThread.FreeOnTerminate := true;
After that line, when the thread does end, it will free the TThread object. That is the object to which FThread points.

So, from this point on, FThread should be treated as a "dangling pointer". Because it can change into that, at any point.

Of course, if you could guarantee that the thread can not finish.... But since you check in the next line, if it has finished, clearly you can not guarantee this.

Code: Pascal  [Select][+][-]
  1.     If not FThread.Finished then  FThread.Terminate; //terminate the process

So you call "Finished", but the object (pointed to by FThread), may already have been destroyed. The result may be random, or the call may even crash.

And even, if the call is made on a still existing object, that is no good, because the object can be freed between the return from "Finished" and the access to "Terminate". Same dangling pointer issue here.


And mind "FThread <> nil" does not help either. After all a dangling pointer is a non-nil value.
And even if the thread would set FThread to nil, before destroying the object. Still a race condition. Still could happen between your check, and the "then" action that requires the check....
 

Gald

  • Full Member
  • ***
  • Posts: 107
Re: Lazarus Release 2.2.0
« Reply #59 on: January 13, 2022, 06:53:08 pm »
It looks like I'm the only one with this trouble.

Project > New Project > Run > Image related.
It can't run my old projects too. I can't run anything.

I've updated it from Lazarus 2.0.12.
What did I do wrong?
Lazarus 2.0.12 r64642 FPC 3.2.0 x86_64-win64-win32/win64/Manjaro KDE 21
AMD Ryzen 3 1300X Quad-Core Processor 3.50 GHz / 8,00 GB RAM / GTX 1500 TI / 2TB M.2 NVMe

 

TinyPortal © 2005-2018