Lazarus
Installation => macOS / Mac OS X => Topic started by: Grahame Grieve 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?
-
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.
-
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?
-
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.
-
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
-
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;
-
Well, at least, that's one line that causes it. That line used to compile on Mac M1, btw
-
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.
-
btw, this is fairly straight forward to reproduce: get the GitHub repo
Which github repo? I don't see any mentioned in your messages.
-
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".
-
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.
-
I get a similar issue here on a RPI4.
https://gitlab.com/freepascal.org/fpc/source/-/issues/39336
-
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
-
Can you try again with latest trunk?
-
Seems to be - thanks!
(at least, now I have other problems to sort out, which appear to be linking errors)