Recent

Author Topic: Lazarus Release 2.2.0  (Read 21349 times)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7689
  • Debugger - SynEdit - and more
    • wiki
Re: Lazarus Release 2.2.0
« Reply #60 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

  • Jr. Member
  • **
  • Posts: 78
Re: Lazarus Release 2.2.0
« Reply #61 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

dsiders

  • Hero Member
  • *****
  • Posts: 563
Re: Lazarus Release 2.2.0
« Reply #62 on: January 13, 2022, 07:17:44 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?

The Note messages are telling you that you have duplicate code in components/freetype and components/lazutils. FreeType was moved into its own package in 2.2.0. https://wiki.lazarus.freepascal.org/Lazarus_2.2.0_release_notes#LazFreeType

I don't know how you updated from 2.0.12 to 2.2.0... but it has remnants of the old version.
Lazarus 2.0.12, 2.2.0, 2.3.0 (Git) / FPC 3.2.0, 3.2.2 / x86 64-bit / Windows 8.1

jonyrh

  • New member
  • *
  • Posts: 6
Re: Lazarus Release 2.2.0
« Reply #63 on: January 14, 2022, 05:00:07 am »
Thank you all for your hard work, I really like Lazarus!  ::)

Sieben

  • Sr. Member
  • ****
  • Posts: 255
Re: Lazarus Release 2.2.0
« Reply #64 on: January 15, 2022, 06:14:47 pm »
'Change Class' not working in 2.2.0...? Whatever I choose, it just doesn't do anything - no errors, just nothing. Any setting I am missing...?
Lazarus 2.0.10, FPC 3.2.0, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

wp

  • Hero Member
  • *****
  • Posts: 9171
Re: Lazarus Release 2.2.0
« Reply #65 on: January 15, 2022, 06:39:32 pm »
'Change Class' not working in 2.2.0...? Whatever I choose, it just doesn't do anything - no errors, just nothing. Any setting I am missing...?
Cannot confirm with Windows 11 and out-of-the-box settings.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

calebs

  • Full Member
  • ***
  • Posts: 151
Re: Lazarus Release 2.2.0
« Reply #66 on: January 23, 2022, 10:19:04 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

Hello jurassic i've had some problems with fpdebug and executing external programs in the past, it was related to 32 and 64 bit mix in windows i recall. . In that situations i changed to gdb and worked well. You can test to change to gdb debugger to isolate the problem, martin_fr was very helpful last time i have that issue.

 

TinyPortal © 2005-2018