View Issue Details

IDProjectCategoryView StatusLast Update
0036774LazarusUtilitiespublic2020-07-13 15:18
ReporterJ. Gareth Moreton Assigned To 
PriorityurgentSeveritycrashReproducibilityalways
Status newResolutionopen 
Platformx86_64-win64OSMicrosoft Windows 
Summary0036774: Using "make" to build Lazarus results in an access violation
DescriptionWhen attempting to build Lazarus with "make all", the compiler raises an access violation - e.g:

...
make -C ide ide
make[1]: Entering directory `C:/Users/NLO-012/Documents/Programming/lazarus/ide'
../tools/svn2revisioninc.exe .. revision.inc
An unhandled exception occurred at $000000010000919A:
EAccessViolation: Access violation
  $000000010000919A
  $000000010000F318
  $000000010000F0FF
  $000000010000E40B
  $000000010000DECE
  $000000010003980D
  $0000000100001882 fin$00000010, line 118 of svn2revisioninc.pas
  $000000010000190D SVNINPATH, line 109 of svn2revisioninc.pas
  $0000000100003D75 PARAMSVALID, line 572 of svn2revisioninc.pas
  $00000001000047ED GITREVISIONFROMGITCOMMIT, line 769 of svn2revisioninc.pas
  $00000001000048E7 main, line 788 of svn2revisioninc.pas
  $0000000100004906
  $00000001000159E0
  $0000000100001856
  $00007FF91D487BD4
  $00007FF91DD8CED1

make[1]: *** [revisioninc] Error 217
make[1]: Leaving directory `C:/Users/NLO-012/Documents/Programming/lazarus/ide'
make: *** [ide] Error 2
Steps To ReproduceWith the most up-to-date files for Lazarus and FPC, attempt to build Lazarus with the following command line:

make clean all FPC="\pp\bin\x86_64-win64\ppcx64.exe" (replace the directory with where the compiler executable gets installed.
Additional InformationThe compiler was built using the following command line:

make distclean all install DATA2INC=C:\Users\NLO-012\Documents\Programming\fpc\utils\bin\x86_64-win64\data2inc.exe OPT="-O4"

Find attached my error log (generated by specifying "> errorlog.log 2>&1" after the make command.
Tagsaccess violation, compiler, lazarus, x86_64, x86_64-win64
Fixed in Revision
LazTarget-
Widgetset
Attached Files

Relationships

related to 0037305 new FPC For loop with try finally statement using -O3 or -O4 causes SIGSEGV 

Activities

J. Gareth Moreton

2020-03-08 23:55

reporter  

errorlog.log (701,828 bytes)

Marco van de Voort

2020-03-09 10:09

manager   ~0121483

Not it doesn't

1. you are in a lazarus dir
2 you run a svn2revision binary from lazarus that crashes

-> lazarus

J. Gareth Moreton

2020-03-09 10:36

reporter   ~0121484

Okay, sorry.

Cyrax

2020-03-09 10:39

reporter   ~0121485

Please add USESVN2REVISIONINC=0 make option if your Lazarus directory isn't under Subversion version control.

J. Gareth Moreton

2020-03-09 11:21

reporter   ~0121487

It is under SVN version control.

Bart Broersma

2020-03-09 12:09

developer   ~0121490

Can you add "-gl" to OPT, so svn2revision gets built with that as well, and we get better backtrace from svn2revision.

J. Gareth Moreton

2020-03-09 22:28

reporter   ~0121507

Error log with -gl option.
errorlog2.log (736,513 bytes)

J. Gareth Moreton

2020-03-13 06:25

reporter   ~0121579

Issue still occurs as of the latest trunk (for both FPC and Lazarus).

Anton Kavalenka

2020-03-13 10:46

reporter   ~0121584

Nice: line 118 of svn2revisioninc.pas
P := TProcessUTF8.Create(nil);
  try
    P.Options := [poUsePipes, poWaitOnExit];
    P.CommandLine := 'svn --version';
    try
      P.Execute;
    except
      Result := False;
    end;
  finally
    P.Destroy; //!!!!!
  end;

i thought the P.Free calls destructor and releases memory.

Anton Kavalenka

2020-03-13 10:47

reporter   ~0121586

There are lots of P.Destroy there

Marco van de Voort

2020-03-13 10:51

manager   ~0121587

No, p.free calls p.destroy. It is a non virtual wrapper for p.destroy.

Anton Kavalenka

2020-03-13 11:03

reporter   ~0121588

so the problem in codegen - target back to FPC?

Marco van de Voort

2020-03-13 11:55

manager   ~0121589

Unless you really can point to where the compiler goes wrong, I'd assume it is the code, not the compiler.

E.g. maybe something in TProcessUTF8 interacts with the updated tprocess (allthough that is also more than an year old), or simply bugs in svn2* itself. Try stepping through the trpocessutf8 destructor

J. Gareth Moreton

2020-03-13 17:06

reporter   ~0121595

Unless I'm mistaken, Free is just a safety wrapper for Destroy - it checks to see if the object is not nil before calling Destroy. To hazard a guess, I would say there's a bug in TProcessUTF8.Destroy itself.

Logically, P should contain a valid object in that block (if TProcessUTF8.Create raises an exception, the try..finally block isn't even entered), so unless something else is corrupting P, I'm not sure what else it could be.

Juha Manninen

2020-03-13 21:31

developer   ~0121597

I took function SvnInPath from svn2revisioninc.pas into my test project.
I changed the command line to:
  P.CommandLine := 'pööö --version';
which certainly does not exist in system path.
The code works as expected. Process raises an exception because 'pööö' does not exist. Function SvnInPath catches it and returns False. No other exceptions. No crashes.
I am testing with Lazarus trunk and FPC trunk from few weeks ago.

J. Gareth Moreton, you built FPC with -O4. Is it safe? Does building with -O3 make a difference?

Marco van de Voort

2020-03-13 22:03

manager   ~0121598

Juha: do you test with win64? Might be a problem in some windows header.

Bart Broersma

2020-03-13 23:29

developer   ~0121599

I was able to build Lazarus trunk (r62767) with ppcrossx64.exe of fpc trunk (r44297).
No crash in svn2revsioninc.exe
All this on Win10-64.

Juha Manninen

2020-03-14 08:57

developer   ~0121600

I tested with Manjaro Linux 64bit. Forgot to mention.

Benjamin Rosseaux

2020-06-05 02:50

reporter   ~0123236

svn2revisioninc.exe crashes also at me as Win64 build (fpc trunk r45361)

An unhandled exception occurred at $000000010000904A:
EAccessViolation: Access violation
  $000000010000904A
  $000000010000F168
  $000000010000EF4F
  $000000010000E25B
  $000000010000DD1E
  $000000010003993D
  $00000001000018A2 fin$00000010, line 118 of svn2revisioninc.pas
  $000000010000192D SVNINPATH, line 109 of svn2revisioninc.pas
  $0000000100003D95 PARAMSVALID, line 572 of svn2revisioninc.pas
  $000000010000480D GITREVISIONFROMGITCOMMIT, line 769 of svn2revisioninc.pas
  $0000000100004907 main, line 788 of svn2revisioninc.pas
  $0000000100004926
  $0000000100015CB0
  $0000000100001876
  $00007FFA76C57BD4
  $00007FFA780CCE51

Bart Broersma

2020-06-06 14:35

developer   ~0123262

Can you make svn2revisioninc crash stand-alone?
If so, with what compiler options was it built?
Can you invoke the crash when building with -gh (heaptrace), might give some additional info

J. Gareth Moreton

2020-07-13 03:11

reporter   ~0123948

I ran "make clean all install FPCOPT="-gh"" - not sure how helpful this heaptrace is:

Heap dump by heaptrc unit of "C:\Users\NLO-012\Documents\Programming\lazarus\tools\svn2revisioninc.exe"
15290 memory blocks allocated : 1752068/1752768
15280 memory blocks freed : 1750837/1751528
10 unfreed memory blocks : 1231
True heap size : 688128 (640 used in System startup)
True free heap : 684032
Should be : 684328
Call trace for block $000000000159DBA0 size 40
  $00000001000106FB
  $00000001000164D5
  $00000001000165BC
  $00007FFE11E411CF
  $00007FFE11E0A209
  $00007FFE11E3FE3E
  $000000010000929A
  $000000010000F388
  $000000010000F16F
  $000000010000E48B
  $000000010000DF4E
  $000000010003BF9D
  $00000001000018B2 fin$00000010, line 118 of svn2revisioninc.pas
  $000000010000193D SVNINPATH, line 109 of svn2revisioninc.pas
  $0000000100003DA5 PARAMSVALID, line 572 of svn2revisioninc.pas
  $000000010000481D GITREVISIONFROMGITCOMMIT, line 769 of svn2revisioninc.pas
Call trace for block $0000000001625D00 size 128
  $0000000100018057
  $00000001000106DB
  $000000010001626F
  $00000001000164BE
  $00000001000165BC
  $00007FFE11E411CF
  $00007FFE11E0A209
  $00007FFE11E3FE3E
  $000000010000929A
  $000000010000F388
  $000000010000F16F
  $000000010000E48B
  $000000010000DF4E
  $000000010003BF9D
  $00000001000018B2 fin$00000010, line 118 of svn2revisioninc.pas
  $000000010000193D SVNINPATH, line 109 of svn2revisioninc.pas
Call trace for block $000000000162DE90 size 176
  $0000000100010642
  $000000010000DE9A
  $0000000100037999
  $000000010003AC27
  $0000000100016493
  $00000001000165BC
  $00007FFE11E411CF
  $00007FFE11E0A209
  $00007FFE11E3FE3E
  $000000010000929A
  $000000010000F388
  $000000010000F16F
  $000000010000E48B
  $000000010000DF4E
  $000000010003BF9D
  $00000001000018B2 fin$00000010, line 118 of svn2revisioninc.pas
Call trace for block $000000000162DD10 size 152
  $0000000100010642
  $000000010000DE9A
  $0000000100023549
  $0000000100049630 SETPROCESSHANDLE, line 568 of utf8process.pp
  $0000000100049E91 EXECUTE, line 665 of utf8process.pp
  $0000000100001928 SVNINPATH, line 113 of svn2revisioninc.pas
  $0000000100003DA5 PARAMSVALID, line 572 of svn2revisioninc.pas
  $000000010000481D GITREVISIONFROMGITCOMMIT, line 769 of svn2revisioninc.pas
  $0000000100004917 main, line 788 of svn2revisioninc.pas
  $0000000100004936
  $0000000100015FB0
  $0000000100001886
  $00007FFE106A7BD4
  $00007FFE11E0CE51
Call trace for block $000000000159D7A0 size 28
  $0000000100010642
  $0000000100009223
  $000000010000A3AF
  $000000010003BD24
  $000000010003BB8C
  $000000010003C44C
  $000000010003C28E
  $0000000100001916 SVNINPATH, line 111 of svn2revisioninc.pas
  $0000000100003DA5 PARAMSVALID, line 572 of svn2revisioninc.pas
  $000000010000481D GITREVISIONFROMGITCOMMIT, line 769 of svn2revisioninc.pas
  $0000000100004917 main, line 788 of svn2revisioninc.pas
  $0000000100004936
  $0000000100015FB0
  $0000000100001886
  $00007FFE106A7BD4
  $00007FFE11E0CE51
Call trace for block $00000000015B16D0 size 296
  $0000000100010642
  $000000010000DE9A
  $000000010003BE19
  $00000001000018F3 SVNINPATH, line 108 of svn2revisioninc.pas
  $0000000100003DA5 PARAMSVALID, line 572 of svn2revisioninc.pas
  $000000010000481D GITREVISIONFROMGITCOMMIT, line 769 of svn2revisioninc.pas
  $0000000100004917 main, line 788 of svn2revisioninc.pas
  $0000000100004936
  $0000000100015FB0
  $0000000100001886
  $00007FFE106A7BD4
  $00007FFE11E0CE51
Call trace for block $00000000015B9840 size 76
  $0000000100010642
  $0000000100009223
  $000000010000A3AF
  $000000010002DF1E
  $0000000100003B98 PARAMSVALID, line 560 of svn2revisioninc.pas
  $000000010000481D GITREVISIONFROMGITCOMMIT, line 769 of svn2revisioninc.pas
  $0000000100004917 main, line 788 of svn2revisioninc.pas
  $0000000100004936
  $0000000100015FB0
  $0000000100001886
  $00007FFE106A7BD4
  $00007FFE11E0CE51
Call trace for block $00000000015D1A80 size 88
  $0000000100010642
  $0000000100009223
  $000000010000A2DA
  $000000010000A33E
  $0000000100042659 RESOLVEDOTS, line 179 of lazfileutils.inc
  $0000000100042DAD EXPANDFILENAMEUTF8, line 406 of winlazfileutils.inc
  $00000001000038A0 PARAMSVALID, line 525 of svn2revisioninc.pas
  $000000010000481D GITREVISIONFROMGITCOMMIT, line 769 of svn2revisioninc.pas
  $0000000100004917 main, line 788 of svn2revisioninc.pas
  $0000000100004936
  $0000000100015FB0
  $0000000100001886
  $00007FFE106A7BD4
  $00007FFE11E0CE51
Call trace for block $000000000159D4A0 size 31
  $0000000100010642
  $0000000100009223
  $000000010000A17B
  $000000010000B5BE
  $0000000100043C7B PARAMSTRUTF8WIDE, line 218 of winlazutf8.inc
  $000000010004363D PARAMSTRUTF8, line 23 of winlazutf8.inc
  $000000010000385C PARAMSVALID, line 524 of svn2revisioninc.pas
  $000000010000481D GITREVISIONFROMGITCOMMIT, line 769 of svn2revisioninc.pas
  $0000000100004917 main, line 788 of svn2revisioninc.pas
  $0000000100004936
  $0000000100015FB0
  $0000000100001886
  $00007FFE106A7BD4
  $00007FFE11E0CE51
Call trace for block $00000000015C16B0 size 216
  $0000000100010642
  $000000010000DE9A
  $0000000100002B1C GETREVISIONFROMGITVERSION, line 213 of svn2revisioninc.pas
  $0000000100004904 main, line 787 of svn2revisioninc.pas
  $0000000100004936
  $0000000100015FB0
  $0000000100001886
  $00007FFE106A7BD4
  $00007FFE11E0CE51

J. Gareth Moreton

2020-07-13 03:25

reporter   ~0123949

Also to note, compiling the tool by itself without any compiler options raises an access violation:

\pp\bin\x86_64-win64\fpc.exe -Fu..\components\lazutils svn2revisioninc.pas (from the "tools" subdirectory)

Then running "svn2revisioninc.exe .. revision.inc":

An unhandled exception occurred at $0000000100008E8A:
EAccessViolation: Access violation
  $0000000100008E8A
  $000000010000EF78
  $000000010000ED5F
  $000000010000E07B
  $000000010000DB3E
  $00000001000362ED
  $0000000100001882
  $000000010000190D
  $0000000100003D75
  $00000001000047ED
  $00000001000048E7
  $0000000100004906
  $00000001000152E0
  $0000000100001856
  $00007FFE106A7BD4
  $00007FFE11E0CE51

J. Gareth Moreton

2020-07-13 05:00

reporter   ~0123950

If -O2 is used instead of -O4, the access violation does not occur. The compiler seems to be producing bad code in this mode. I'll see what I can find.

Zeljan Rikalo

2020-07-13 09:53

developer   ~0123955

Maybe related to https://bugs.freepascal.org/view.php?id=37305

Issue History

Date Modified Username Field Change
2020-03-08 23:55 J. Gareth Moreton New Issue
2020-03-08 23:55 J. Gareth Moreton File Added: errorlog.log
2020-03-08 23:57 J. Gareth Moreton Tag Attached: compiler
2020-03-08 23:57 J. Gareth Moreton Tag Attached: x86_64
2020-03-08 23:57 J. Gareth Moreton Tag Attached: x86_64-win64
2020-03-08 23:57 J. Gareth Moreton Tag Attached: lazarus
2020-03-08 23:57 J. Gareth Moreton Tag Attached: access violation
2020-03-09 00:13 J. Gareth Moreton Priority normal => urgent
2020-03-09 00:13 J. Gareth Moreton Severity minor => crash
2020-03-09 00:13 J. Gareth Moreton FPCTarget => -
2020-03-09 10:08 Marco van de Voort Project FPC => Lazarus
2020-03-09 10:09 Marco van de Voort Note Added: 0121483
2020-03-09 10:10 Marco van de Voort Category Compiler => Utilities
2020-03-09 10:10 Marco van de Voort Product Version 3.3.1 =>
2020-03-09 10:10 Marco van de Voort LazTarget => -
2020-03-09 10:36 J. Gareth Moreton Note Added: 0121484
2020-03-09 10:39 Cyrax Note Added: 0121485
2020-03-09 11:21 J. Gareth Moreton Note Added: 0121487
2020-03-09 12:09 Bart Broersma Note Added: 0121490
2020-03-09 22:28 J. Gareth Moreton File Added: errorlog2.log
2020-03-09 22:28 J. Gareth Moreton Note Added: 0121507
2020-03-13 06:25 J. Gareth Moreton Note Added: 0121579
2020-03-13 10:46 Anton Kavalenka Note Added: 0121584
2020-03-13 10:47 Anton Kavalenka Note Added: 0121586
2020-03-13 10:51 Marco van de Voort Note Added: 0121587
2020-03-13 11:03 Anton Kavalenka Note Added: 0121588
2020-03-13 11:55 Marco van de Voort Note Added: 0121589
2020-03-13 17:06 J. Gareth Moreton Note Added: 0121595
2020-03-13 21:31 Juha Manninen Note Added: 0121597
2020-03-13 22:03 Marco van de Voort Note Added: 0121598
2020-03-13 23:29 Bart Broersma Note Added: 0121599
2020-03-14 08:57 Juha Manninen Note Added: 0121600
2020-06-05 02:50 Benjamin Rosseaux Note Added: 0123236
2020-06-06 14:35 Bart Broersma Note Added: 0123262
2020-07-13 03:11 J. Gareth Moreton Note Added: 0123948
2020-07-13 03:25 J. Gareth Moreton Note Added: 0123949
2020-07-13 05:00 J. Gareth Moreton Note Added: 0123950
2020-07-13 09:53 Zeljan Rikalo Note Added: 0123955
2020-07-13 15:18 Maxim Ganetsky Relationship added related to 0037305