Recent

Author Topic: TDeque issue on MacOS Arm M1  (Read 8171 times)

powerpcer

  • Jr. Member
  • **
  • Posts: 62
TDeque issue on MacOS Arm M1
« on: December 13, 2021, 07:30:44 am »
TDeque.ClearData; this method should change to this
Code: Pascal  [Select][+][-]
  1. procedure TDeque.ClearData;
  2. var
  3.   i: SizeUint;
  4. begin
  5.   if IsManagedType(T) then
  6.     if FData <> nil then //<--add checking, else When FData is nil(why not happen on Windows?)
  7.     for i := Low(FData) to High(FData) do
  8.       Finalize(FData[i]);
  9.   FillChar(FData[Low(FData)], SizeUInt(Length(FData))*SizeOf(T), 0);
  10. end;
  11.  

Bart

  • Hero Member
  • *****
  • Posts: 4689
    • Bart en Mariska's Webstek
Re: TDeque issue on MacOS Arm M1
« Reply #1 on: December 13, 2021, 12:06:55 pm »
Please file a bugreport on the FPC issue tracker.

Bart

AlexTP

  • Hero Member
  • *****
  • Posts: 1761
    • UVviewsoft
Re: TDeque issue on MacOS Arm M1
« Reply #2 on: December 13, 2021, 12:30:40 pm »
I don't get your idea, how macOS can be 'bad' here and Windows can be ok here? Code is crossplatform! Show the failing small project.

PascalDragon

  • Hero Member
  • *****
  • Posts: 3998
  • Compiler Developer
Re: TDeque issue on MacOS Arm M1
« Reply #3 on: December 13, 2021, 01:41:55 pm »
TDeque.ClearData; this method should change to this

Please provide a complete example that fails.

powerpcer

  • Jr. Member
  • **
  • Posts: 62
Re: TDeque issue on MacOS Arm M1
« Reply #4 on: December 13, 2021, 10:21:42 pm »
I don't get your idea, how macOS can be 'bad' here and Windows can be ok here? Code is crossplatform! Show the failing small project.
i just build your old version CudaText 1.95.x , it work!!
but when the App close in the FormDestroy of FormMain, the freeandnil(FconsoleQueue) report me access violation.
and follow the debugger, it show me Fdata on TDeque.ClearData is Nil, and Low(Fdata) to High(Fdata) work, so Finalize(Fdata) got access violation.
my FPC version is 3.2.2 come from FPCDeluxe project.

AlexTP

  • Hero Member
  • *****
  • Posts: 1761
    • UVviewsoft
Re: TDeque issue on MacOS Arm M1
« Reply #5 on: December 13, 2021, 10:36:38 pm »
I cannot reproduce this in the CudaText because I don't support such OLD versions! In app 1.152, the code is changed (and no error)
Code: Pascal  [Select][+][-]
  1. initialization // proc_globdata.pas
  2.   AppConsoleQueue:= TAppConsoleQueue.Create;  
  3. finalization
  4.   FreeAndNil(AppConsoleQueue);    
  5.  

powerpcer

  • Jr. Member
  • **
  • Posts: 62
Re: TDeque issue on MacOS Arm M1
« Reply #6 on: December 14, 2021, 12:39:17 am »
I cannot reproduce this in the CudaText because I don't support such OLD versions! In app 1.152, the code is changed (and no error)
Code: Pascal  [Select][+][-]
  1. initialization // proc_globdata.pas
  2.   AppConsoleQueue:= TAppConsoleQueue.Create;  
  3. finalization
  4.   FreeAndNil(AppConsoleQueue);    
  5.  
because FConsoleQueue:= TAppConsoleQueue.Create;   was created in FormCreate of FormMain
so, that's why FreeAndNil(FConsoleQueue); not explode, . but same time, i build it in x86 MacOS is working correctly.

AlexTP

  • Hero Member
  • *****
  • Posts: 1761
    • UVviewsoft
Re: TDeque issue on MacOS Arm M1
« Reply #7 on: December 14, 2021, 12:55:28 am »
So we don't have a repro project / repro in my editor.

powerpcer

  • Jr. Member
  • **
  • Posts: 62
Re: TDeque issue on MacOS Arm M1
« Reply #8 on: December 14, 2021, 02:26:14 am »
So we don't have a repro project / repro in my editor.
Exception: EXC_BAD_ACCESS
Reproduce, just make an Application with a Form with code below, very simple
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs,gqueue;
  9.  
  10. type
  11.   TAppConsoleQueue = specialize Tqueue<string>;
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     procedure FormCreate(Sender: TObject);
  17.     procedure FormDestroy(Sender: TObject);
  18.   private
  19.     FConsoleQueue:TAppConsoleQueue;
  20.   public
  21.  
  22.   end;
  23.  
  24. var
  25.   Form1: TForm1;
  26.  
  27. implementation
  28.  
  29. {$R *.lfm}
  30.  
  31. { TForm1 }
  32.  
  33. procedure TForm1.FormCreate(Sender: TObject);
  34. begin
  35.    FConsoleQueue:=TAppConsoleQueue.Create;
  36. end;
  37.  
  38. procedure TForm1.FormDestroy(Sender: TObject);
  39. begin
  40.   FreeAndNil(FConsoleQueue);
  41. end;
  42.  
  43. end.
  44.  

PascalDragon

  • Hero Member
  • *****
  • Posts: 3998
  • Compiler Developer
Re: TDeque issue on MacOS Arm M1
« Reply #9 on: December 14, 2021, 09:17:23 am »
So we don't have a repro project / repro in my editor.
Exception: EXC_BAD_ACCESS
Reproduce, just make an Application with a Form with code below, very simple

This is not a complete example. Either provide one that doesn't depend on the LCL or use the publish project option to provide the complete project.

powerpcer

  • Jr. Member
  • **
  • Posts: 62
Re: TDeque issue on MacOS Arm M1
« Reply #10 on: December 14, 2021, 11:32:11 am »
So we don't have a repro project / repro in my editor.
Exception: EXC_BAD_ACCESS
Reproduce, just make an Application with a Form with code below, very simple

This is not a complete example. Either provide one that doesn't depend on the LCL or use the publish project option to provide the complete project.
for what purpose?

bytebites

  • Sr. Member
  • ****
  • Posts: 473
Re: TDeque issue on MacOS Arm M1
« Reply #11 on: December 14, 2021, 12:45:06 pm »
Complete Lazarus project attached, no error in linux.

PascalDragon

  • Hero Member
  • *****
  • Posts: 3998
  • Compiler Developer
Re: TDeque issue on MacOS Arm M1
« Reply #12 on: December 14, 2021, 01:28:39 pm »
So we don't have a repro project / repro in my editor.
Exception: EXC_BAD_ACCESS
Reproduce, just make an Application with a Form with code below, very simple

This is not a complete example. Either provide one that doesn't depend on the LCL or use the publish project option to provide the complete project.
for what purpose?

If we can't reproduce the problem then there is no way for us to fix it. And with partial code it is very likely that it's something else that triggers the problem, namely something that was left out. This has happened in the past, thus a complete example to reproduce the problem is very important.

Can you reproduce the problem with the project provided by bytebites?

powerpcer

  • Jr. Member
  • **
  • Posts: 62
Re: TDeque issue on MacOS Arm M1
« Reply #13 on: December 15, 2021, 12:10:06 am »
So we don't have a repro project / repro in my editor.
Exception: EXC_BAD_ACCESS
Reproduce, just make an Application with a Form with code below, very simple

This is not a complete example. Either provide one that doesn't depend on the LCL or use the publish project option to provide the complete project.
for what purpose?

If we can't reproduce the problem then there is no way for us to fix it. And with partial code it is very likely that it's something else that triggers the problem, namely something that was left out. This has happened in the past, thus a complete example to reproduce the problem is very important.

Can you reproduce the problem with the project provided by bytebites?
bytebites's code run on ARM M1 MacOS when clicking close button, will raise exception, he reproduced it!! it is simple like that.
attach is my build.
« Last Edit: December 15, 2021, 12:20:47 am by powerpcer »

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 963
Re: TDeque issue on MacOS Arm M1
« Reply #14 on: April 09, 2022, 08:42:36 pm »

 

TinyPortal © 2005-2018