Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2021-07

Going to properly investigate that 3.0.2 bug

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

J. Gareth Moreton

Hi everyone,

So I want to fix that optimisation bug in FPC 3.0.2 and 3.2.0 etc, but I need a little bit of help.  I know that Lazarus doesn't build properly with optimisations, but does anyone know of a smaller project that compiles incorrectly and causes an easy crash when run?  If not, what do I need to do with Lazarus to make it crash?  With that, I can do a kind of manual binary search with revisions to find the point where it no longer crashes (since it was fixed for FPC 3.3.1).

Gareth aka. Kit

This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

Reply by email

Martin Frb
to J. Gareth Moreton
J. Gareth Moreton wrote 9 lines
Hi everyone, So I want to fix that optimisation bug in FPC 3.0.2 and 3.2.0 etc, but I need a little bit of help.  I know that Lazarus doesn't build properly with optimisations, but does anyone know of a smaller project that compiles incorrectly and causes an easy crash when run?  If not, what do I need to do with Lazarus to make it crash?  With that, I can do a kind of manual binary search with revisions to find the point where it no longer crashes (since it was fixed for FPC 3.3.1).

The one that I got is very hard to catch.

It seem to me, that something is doing a write to random memory. So any tiny change, and the bug disappears.

This is the revision that for me reproduces it.
https://github.com/User4martin/lazarus/tree/f-fpc-crash-fpdebug

The testcase is
components\lazdebuggers\lazdebuggerfp\test\LazDebFpTest.lpi build mode "64bit -O2"

To run it you need to copy    fpclist.txt.sample   to  fpclist.txt edit it, and point it to your fpc (can be an older, can be trunk, does not have to be the crashing version)
you need only one fpc in it.

You also need to create some folders
logs/
lib/
testapps/lib/

And it is Windows 64 bit only.

Make sure it crashes  for you, before trying to hunt down what it is.

-------------------------------------

I tried to create a console test case => but then it does not crash.

If you use OoNOPEEPHOLE  => no crash

If you use "implicit exception off" => no crash
see https://github.com/User4martin/lazarus/tree/f-fpdebug-fpc-optimizer-bug

I did trace it down to the specialization of some generic, that needed to be done while "implicit exception off"
But that is a lot of functions...

-----
All that said, I know there is no proof the bug is not in my code. It's just based on likelyhood.

I valgrinded the crap out of it. Nothing.
Well it is only windows, but if I accessed a dangling pointer, valgrind would find it, even if it caused no harm on Linux. So the bug is apparently not in the compiled code on Linux.

And that is basically all I have....

--------------------------
you can edit the project file and change

   TestRunner.RunExecute(TestRunner);
   //Application.Run;

then the test runs automatically.

Or even
   TestRunner.Show;
TestRunner.RunTest(TTest(TestRunner.TestTree.Items[0].Items[2].Data));

To run just a small subset of tests (you might need to change that depending on your fpclist.txt)

Reply by email

J. Gareth Moreton
to Martin Frb

That's got to be the worst kind of bug - I know it's been fixed but I can't remember what fix it was (assuming it was me who fixed it).  Without a reproducible case I can't exactly identify the patch that fixes it, and yet I don't want to leave FPC 3.2.0 in a state where the optimizer is in an unreliable state.

Gareth aka. Kit

Martin Frb wrote 85 lines
On 10/07/2021 06:40, J. Gareth Moreton via fpc-devel wrote: > Hi everyone, > > So I want to fix that optimisation bug in FPC 3.0.2 and 3.2.0 etc, > but I need a little bit of help.  I know that Lazarus doesn't build > properly with optimisations, but does anyone know of a smaller > project that compiles incorrectly and causes an easy crash when run?  > If not, what do I need to do with Lazarus to make it crash?  With > that, I can do a kind of manual binary search with revisions to find > the point where it no longer crashes (since it was fixed for FPC 3.3.1). The one that I got is very hard to catch. It seem to me, that something is doing a write to random memory. So any tiny change, and the bug disappears. This is the revision that for me reproduces it. https://github.com/User4martin/lazarus/tree/f-fpc-crash-fpdebug The testcase is components\lazdebuggers\lazdebuggerfp\test\LazDebFpTest.lpi build mode "64bit -O2" To run it you need to copy    fpclist.txt.sample   to  fpclist.txt edit it, and point it to your fpc (can be an older, can be trunk, does not have to be the crashing version) you need only one fpc in it. You also need to create some folders logs/ lib/ testapps/lib/ And it is Windows 64 bit only. Make sure it crashes  for you, before trying to hunt down what it is. ------------------------------------- I tried to create a console test case => but then it does not crash. If you use OoNOPEEPHOLE  => no crash If you use "implicit exception off" => no crash see https://github.com/User4martin/lazarus/tree/f-fpdebug-fpc-optimizer-bug I did trace it down to the specialization of some generic, that needed to be done while "implicit exception off" But that is a lot of functions... ----- All that said, I know there is no proof the bug is not in my code. It's just based on likelyhood. I valgrinded the crap out of it. Nothing. Well it is only windows, but if I accessed a dangling pointer, valgrind would find it, even if it caused no harm on Linux. So the bug is apparently not in the compiled code on Linux. And that is basically all I have.... -------------------------- you can edit the project file and change   TestRunner.RunExecute(TestRunner);   //Application.Run; then the test runs automatically. Or even   TestRunner.Show; TestRunner.RunTest(TTest(TestRunner.TestTree.Items[0].Items[2].Data)); To run just a small subset of tests (you might need to change that depending on your fpclist.txt) _______________________________________________ fpc-devel maillist  -  https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

Reply by email

J. Gareth Moreton
to Olly Cain

The fact that it's fixed in FPC 3.2.2 is not too hopeful, but we can't ignore evidence!  Hopefully there's a clue somewhere.

What I really need is a sample that causes a crash in 3.2.2 but not 3.3.1, but as you said, this bug seems to be rather unpredictable.

Gareth aka. Kit

Olly Cain wrote 11 lines
Not what Martin is experiencing as this is related to loop unrolling (O3 and O4) but it could help. Also was only an issue in 3.2.0. https://bugs.freepascal.org/view.php?id=37305 _______________________________________________ fpc-devel maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

Reply by email