Igor,
It is hard to provide any guidance without seeing the source code of SysPng.pas. You might want to see if this is specific to Aarch64, or is seen in the FPC trunk for any architecture (I use FPC 3.2 on x86-64, but for Aarch64 we need to use FPC trunk). Next, I would suggest you try to develop a minimal program that elicits this bug and then make a bug report. Here are an example of two bugs I identified when using higher optimization levels:
https://bugs.freepascal.org/view.php?id=37397 https://bugs.freepascal.org/view.php?id=37393Once I was able to provide concise bug reports, the compiler team was able to resolve them in less than a day.
The trick is isolating the bug. A good example is my issue 0037393, where the faulty procedure returned incorrect values but did not cause a crash - the crash happened much later. It did take a while to work out the root cause of the error. However, since both your code and my code works at lower optimization levels, you can ping-pong between optimization levels to work out the root error.