Recent

Author Topic: Compile Error (Darain/AArch64)  (Read 5628 times)

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 363
Compile Error (Darain/AArch64)
« on: September 13, 2021, 02:16:10 pm »
Compiling my source, quite a lot of it, I get this error:

Error: Compilation raised exception internally
Error: An unhandled exception occurred at $000000010029FB78:
Error: EBusError: Bus error or misaligned data access
Debug:   $000000010029FB78
Debug:   $000000010029FBB4
Debug:   $0000000100334210
Debug:   $000000010029FBB4
Debug:   $000000010029AE08
Debug:   $000000010029FBB4
Debug:   $0000000100336718
Debug:   $000000010029FBB4
Debug:   $000000010033882C
Debug:   $000000010029FBB4
Debug:   $0000000100330414
Debug:   $000000010029FBB4
Debug:   $0000000100332F2C
Debug:   $000000010029FBB4
Debug:   $0000000100336718
Debug:   $000000010029FBB4
Debug:   $000000010033167C
Debug:
Verbose: Compilation aborted
Verbose: /Users/grahame/tools/lazarus/fpc/bin/aarch64-darwin/ppca64 returned an error exitcode

There's no line, or even source unit associated with this error, so I'm kind of at a loss. It compiles fine for windows64. Any thoughts on what I'd do to investigate?

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1738
Re: Compile Error (Darain/AArch64)
« Reply #1 on: September 13, 2021, 03:43:11 pm »
As the error tells: misaligned data access.
Happens very often on ARM and ARM64 when using pointer magic (or access).
However, I do not know if this is also valid for the sources you are trying to compile.
For me: using the typinfo unit to the max will prevent many of these errors.


I stand corrected. This is indeed a compiler error.
« Last Edit: September 13, 2021, 04:09:00 pm by DonAlfredo »

ccrause

  • Hero Member
  • *****
  • Posts: 843
Re: Compile Error (Darain/AArch64)
« Reply #2 on: September 13, 2021, 04:03:19 pm »
The error messages suggest this is an internal compiler error.  It would help if Grahame can rebuild the compiler with line information added (add option -gl somewhere to the build command).  If this is a release compiler then all information was probably stripped so it would be quite difficult to figure out where in the compiler the error originates from.

Which compiler version is giving this problem?

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: Compile Error (Darain/AArch64)
« Reply #3 on: September 13, 2021, 06:26:47 pm »
On Darwin you need to add -Xg in addition to -gl (and then copy the ppca64.dSYM directory from the compiler directory next to the ppca64 binary). This will also require trunk, or a fairly recent version of the fixes branch.

It's indeed a crash inside the compiler, which is why it's not giving any more information. If you pass -va, you might get some idea of what it was compiling based on the output that appears before the crash.

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 363
Re: Compile Error (Darain/AArch64)
« Reply #4 on: September 18, 2021, 08:04:25 am »
Well, I did a fresh install of lazarus from trunk using FPCUpdeluxe with the options -g -gl -O- -Xg for both Lazarus and FPC, and then recompiled, and got more info:

Error: (1026) Compilation raised exception internally
An unhandled exception occurred at $00000001009E12FC:
EBusError: Bus error or misaligned data access
  $00000001009E12FC line 200 of pass_2.pas
  $00000001009E133C line 211 of pass_2.pas
  $0000000100A86D28 line 1352 of ncgcal.pas
  $00000001009E133C line 211 of pass_2.pas
  $00000001009DB898 line 205 of ncgmem.pas
Fatal: (1018) Compilation aborted
  $00000001009E133C line 211 of pass_2.pas
  $0000000100A8989C line 847 of ncgcnv.pas
  $00000001009E133C line 211 of pass_2.pas
  $0000000100A8BEAC line 729 of ncgld.pas
  $00000001009E133C line 211 of pass_2.pas
  $0000000100A82430 line 475 of ncgbas.pas
  $00000001009E133C line 211 of pass_2.pas
  $0000000100A85798 line 998 of ncgcal.pas
  $00000001009E133C line 211 of pass_2.pas
  $0000000100A8989C line 847 of ncgcnv.pas
  $00000001009E133C line 211 of pass_2.pas
  $0000000100A839DC line 334 of ncgcal.pas


 btw, this is fairly straight forward to reproduce: get the GitHub repo, install the dependent packages (most not in OPM) and then compile one of the packages in the GitHub repo. I can provide details if relevant

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 363
Re: Compile Error (Darain/AArch64)
« Reply #5 on: September 18, 2021, 08:26:11 am »
I chased it down. It's this line:

        so := TFslDecimal.ValueOf(sl).Subtract(TFslDecimal.ValueOf(sr)).AsString

in this routine

function TMXmlDocument.opMinus(left, right: TFslList<TMXmlNode>): TFslList<TMXmlNode>;
var
  sl, sr, so: String;
  dl, dr : TFslDecimal;
begin
  result := TFslList<TMXmlNode>.Create;
  try
    if (left.Count <> 1) or (right.Count <> 1) then
      // nothing
    else
    begin
      sl := evaluateString(left);
      sr := evaluateString(right);
      if StringIsInteger32(sl) and StringIsInteger32(sr) then
        so := IntToStr(StringToInteger32(sl) - StringToInteger32(sr))
      else if StringIsDecimal(sl) and StringIsDecimal(sr) then
        so := TFslDecimal.ValueOf(sl).Subtract(TFslDecimal.ValueOf(sr)).AsString
      else
        so := sl.Replace(sr, '');
    end;
    result.Add(TMXmlString.Create(so));
    result.link;
  finally
    result.free;
  end;
end;             

in https://github.com/grahamegrieve/fhirserver/blob/master/library/fsl/fsl_xml.pas

If I replace that line with this, which is identical but uses two local variables, no problems

        dl := TFslDecimal.ValueOf(sl);
        dr := TFslDecimal.ValueOf(sr);
        so := dl.Subtract(dr).AsString;


Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 363
Re: Compile Error (Darain/AArch64)
« Reply #6 on: September 18, 2021, 08:27:59 am »
Well, at least, that's one line that causes it. That line used to compile on Mac M1, btw

FPK

  • Full Member
  • ***
  • Posts: 118
Re: Compile Error (Darain/AArch64)
« Reply #7 on: September 18, 2021, 10:59:03 am »
On Darwin you need to add -Xg in addition to -gl (and then copy the ppca64.dSYM directory from the compiler directory next to the ppca64 binary). This will also require trunk, or a fairly recent version of the fixes branch.

The copying shouldn't be needed anymore except if the crash is in ppc3 (because if ppc3 is compiled with this name, the compare of the executables will fail), see https://gitlab.com/freepascal.org/fpc/source/-/commit/b3bf183fd37dcb46c4a89fc48005cb68dbed4a50 and friends.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: Compile Error (Darain/AArch64)
« Reply #8 on: September 18, 2021, 07:11:06 pm »
btw, this is fairly straight forward to reproduce: get the GitHub repo
Which github repo? I don't see any mentioned in your messages.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: Compile Error (Darain/AArch64)
« Reply #9 on: September 18, 2021, 07:11:52 pm »
On Darwin you need to add -Xg in addition to -gl (and then copy the ppca64.dSYM directory from the compiler directory next to the ppca64 binary). This will also require trunk, or a fairly recent version of the fixes branch.

The copying shouldn't be needed anymore except if the crash is in ppc3 (because if ppc3 is compiled with this name, the compare of the executables will fail), see https://gitlab.com/freepascal.org/fpc/source/-/commit/b3bf183fd37dcb46c4a89fc48005cb68dbed4a50 and friends.
I meant you need to copy the .dSYM bundle to the installation directory, because afaik our Makefiles don't do that with "make install".

FPK

  • Full Member
  • ***
  • Posts: 118
Re: Compile Error (Darain/AArch64)
« Reply #10 on: September 18, 2021, 07:16:21 pm »
On Darwin you need to add -Xg in addition to -gl (and then copy the ppca64.dSYM directory from the compiler directory next to the ppca64 binary). This will also require trunk, or a fairly recent version of the fixes branch.

The copying shouldn't be needed anymore except if the crash is in ppc3 (because if ppc3 is compiled with this name, the compare of the executables will fail), see https://gitlab.com/freepascal.org/fpc/source/-/commit/b3bf183fd37dcb46c4a89fc48005cb68dbed4a50 and friends.
I meant you need to copy the .dSYM bundle to the installation directory, because afaik our Makefiles don't do that with "make install".

Indeed, that's true.

olly

  • New Member
  • *
  • Posts: 42
Re: Compile Error (Darain/AArch64)
« Reply #11 on: September 18, 2021, 07:30:51 pm »

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 363
Re: Compile Error (Darain/AArch64)
« Reply #12 on: September 18, 2021, 09:46:30 pm »
To reproduce this, install packages from the following repos:
https://github.com/dezlov/PascalTZ
https://github.com/grahamegrieve/delphi-markdown

Then try and compile /packages/fhir_fsl.pas in https://github.com/grahamegrieve/fhirserver on a Mac M1

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: Compile Error (Darain/AArch64)
« Reply #13 on: September 25, 2021, 09:03:52 pm »
Can you try again with latest trunk?

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 363
Re: Compile Error (Darain/AArch64)
« Reply #14 on: September 27, 2021, 06:07:04 am »
Seems to be - thanks!

(at least, now I have other problems to sort out, which appear to be linking errors)

 

TinyPortal © 2005-2018