View Issue Details

IDProjectCategoryView StatusLast Update
0036347FPCMiscpublic2019-11-23 15:05
ReporterAbou Al MontacirAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformx86_64OSDebian GNU/LinuxOS VersionStretch
Product Version3.0.4Product Build3.0.4+dfsg-22 
Target VersionFixed in Version3.3.1 
Summary0036347: fpdoc does not exit correctly after an error
DescriptionThe issue was identified when trying to debug Debian bug https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=939414.
The reason of that bug is that fpdoc fails silently and does not return a non zero exit code.
Steps To Reproduceenter fpcdocs repository after building fpdoc with DEBUG=1 and run the following command (note the use of gdb):
gdb --args ../fpcsrc/utils/fpdoc/bin/x86_64-linux/fpdoc --macro=FPCDIR=../fpcsrc --macro=FPCDIR=../fpcsrc --package=fcl-res --warn-no-node --content=fclres.xct --import=fcl.xct --import=rtl.xct,../rtl/ --input=../fpcsrc/packages/fcl-res/src/resource.pp --descr=../fpcsrc/packages/fcl-res/xml/resource.xml --input=../fpcsrc/packages/fcl-res/src/resourcetree.pp --descr=../fpcsrc/packages/fcl-res/xml/resourcetree.xml --input=../fpcsrc/packages/fcl-res/src/resdatastream.pp --descr=../fpcsrc/packages/fcl-res/xml/resdatastream.xml --input=../fpcsrc/packages/fcl-res/src/resfactory.pp --descr=../fpcsrc/packages/fcl-res/xml/resfactory.xml --input=../fpcsrc/packages/fcl-res/src/resreader.pp --descr=../fpcsrc/packages/fcl-res/xml/resreader.xml --input=../fpcsrc/packages/fcl-res/src/reswriter.pp --descr=../fpcsrc/packages/fcl-res/xml/reswriter.xml --input=../fpcsrc/packages/fcl-res/src/bitmapresource.pp --descr=../fpcsrc/packages/fcl-res/xml/bitmapresource.xml --input=../fpcsrc/packages/fcl-res/src/acceleratorsresource.pp --descr=../fpcsrc/packages/fcl-res/xml/acceleratorsresource.xml --input=../fpcsrc/packages/fcl-res/src/groupresource.pp --descr=../fpcsrc/packages/fcl-res/xml/groupresource.xml --input=../fpcsrc/packages/fcl-res/src/groupiconresource.pp --descr=../fpcsrc/packages/fcl-res/xml/groupiconresource.xml --input=../fpcsrc/packages/fcl-res/src/groupcursorresource.pp --descr=../fpcsrc/packages/fcl-res/xml/groupcursorresource.xml --input=../fpcsrc/packages/fcl-res/src/stringtableresource.pp --descr=../fpcsrc/packages/fcl-res/xml/stringtableresource.xml --input=../fpcsrc/packages/fcl-res/src/versionconsts.pp --descr=../fpcsrc/packages/fcl-res/xml/versionconsts.xml --input=../fpcsrc/packages/fcl-res/src/versiontypes.pp --descr=../fpcsrc/packages/fcl-res/xml/versiontypes.xml --input=../fpcsrc/packages/fcl-res/src/versionresource.pp --descr=../fpcsrc/packages/fcl-res/xml/versionresource.xml --input=../fpcsrc/packages/fcl-res/src/cofftypes.pp --descr=../fpcsrc/packages/fcl-res/xml/cofftypes.xml --input=../fpcsrc/packages/fcl-res/src/coffreader.pp --descr=../fpcsrc/packages/fcl-res/xml/coffreader.xml --input=../fpcsrc/packages/fcl-res/src/coffwriter.pp --descr=../fpcsrc/packages/fcl-res/xml/coffwriter.xml --input=../fpcsrc/packages/fcl-res/src/winpeimagereader.pp --descr=../fpcsrc/packages/fcl-res/xml/winpeimagereader.xml --input=../fpcsrc/packages/fcl-res/src/elfconsts.pp --descr=../fpcsrc/packages/fcl-res/xml/elfconsts.xml --input=../fpcsrc/packages/fcl-res/src/elfreader.pp --descr=../fpcsrc/packages/fcl-res/xml/elfreader.xml --input=../fpcsrc/packages/fcl-res/src/elfwriter.pp --descr=../fpcsrc/packages/fcl-res/xml/elfwriter.xml --input=../fpcsrc/packages/fcl-res/src/machotypes.pp --descr=../fpcsrc/packages/fcl-res/xml/machotypes.xml --input=../fpcsrc/packages/fcl-res/src/machoreader.pp --descr=../fpcsrc/packages/fcl-res/xml/machoreader.xml --input=../fpcsrc/packages/fcl-res/src/machowriter.pp --descr=../fpcsrc/packages/fcl-res/xml/machowriter.xml --input=../fpcsrc/packages/fcl-res/src/externaltypes.pp --descr=../fpcsrc/packages/fcl-res/xml/externaltypes.xml --input=../fpcsrc/packages/fcl-res/src/externalreader.pp --descr=../fpcsrc/packages/fcl-res/xml/externalreader.xml --input=../fpcsrc/packages/fcl-res/src/externalwriter.pp --descr=../fpcsrc/packages/fcl-res/xml/externalwriter.xml --input=../fpcsrc/packages/fcl-res/src/dfmreader.pp --descr=../fpcsrc/packages/fcl-res/xml/dfmreader.xml --format=html --output=fclres

(gdb) r

(gdb) b fcl-base/src/custapp.pp:345

(gdb) n # run this multiuple times until it exists
Additional InformationThere seem wrong exit code handling in doRun method. indeed we can see at fpdoc.pp:413 the following code:
Procedure TFPDocApplication.DoRun;
begin
  try
    ...
  except
    ExitCode:=1;
    Raise;
  end;
end;

However inside the Run method there is also a catch of the exception without reraising it (fcl-base/src/custapp.pp:345):
procedure TCustomApplication.Run;
begin
  Repeat
    Try
      DoRun;
    except
      HandleException(Self);
    end;
  Until FTerminated;
end;

So we never go in the line 413 of fpdoc.pp
TagsNo tags attached.
Fixed in Revision43563
FPCOldBugId
FPCTarget3.2.0
Attached Files

Activities

Michael Van Canneyt

2019-11-23 13:03

administrator   ~0119447

Last edited: 2019-11-23 13:05

View 2 revisions

Of course you get on line 413.
This is executed first, and then the exception is reraised, and caught by tcustomapplication.run

The problem is that the TFPDocCreator catches the errors first in CreateDocumentation, that's why you don't get to 413.
See unit mkfpdoc, line 280 and following:

      except
        on E: EParserError do
          If Options.StopOnParseError then
            Raise
          else
            begin
            DoLog('Error: %s(%d,%d): %s',[E.Filename, E.Row, E.Column, E.Message]);
            DoLog('Ignoring error, continuing with next unit (if any).');
            end;
      end;

StopOnParseError is false by default. The project file contains an option:
stop-on-parser-error
set to true.

Or on the command-line:
--stop-on-parser-error

Abou Al Montacir

2019-11-23 13:59

manager   ~0119449

I don't see any --stop-on-parse-error in the command line. And the project is FPC RTL one, so you may know more than me if there is such a command.
However this is a real issue and fpdoc, as used in FPC documentation does silently pass errors. User does not catch them as the doc build process is very verbose.

The FCL is also failing the same way as you can see in the log snippet that I have copied from https://buildd.debian.org/status/fetch.php?pkg=fpc&arch=all&ver=3.0.4+dfsg-22&stamp=1548969051&raw=0

fpdoc --macro=FPCDIR=../fpcsrc --macro=FPCDIR=../fpcsrc --package=fcl-res --warn-no-node --content=fclres.xct --import=fcl.xct --import=rtl.xct,../rtl/ --input=../fpcsrc/packages/fcl-res/src/resource.pp --descr=../fpcsrc/packages/fcl-res/xml/resource.xml --input=../fpcsrc/packages/fcl-res/src/resourcetree.pp --descr=../fpcsrc/packages/fcl-res/xml/resourcetree.xml --input=../fpcsrc/packages/fcl-res/src/resdatastream.pp --descr=../fpcsrc/packages/fcl-res/xml/resdatastream.xml --input=../fpcsrc/packages/fcl-res/src/resfactory.pp --descr=../fpcsrc/packages/fcl-res/xml/resfactory.xml --input=../fpcsrc/packages/fcl-res/src/resreader.pp --descr=../fpcsrc/packages/fcl-res/xml/resreader.xml --input=../fpcsrc/packages/fcl-res/src/reswriter.pp --descr=../fpcsrc/packages/fcl-res/xml/reswriter.xml --input=../fpcsrc/packages/fcl-res/src/bitmapresource.pp --descr=../fpcsrc/packages/fcl-res/xml/bitmapresource.xml --input=../fpcsrc/packages/fcl-res/src/acceleratorsresource.pp --descr=../fpcsrc/packages/fcl-res/xml/acceleratorsresource.xml --input=../fpcsrc/packages/fcl-res/src/groupresource.pp --descr=../fpcsrc/packages/fcl-res/xml/groupresource.xml --input=../fpcsrc/packages/fcl-res/src/groupiconresource.pp --descr=../fpcsrc/packages/fcl-res/xml/groupiconresource.xml --input=../fpcsrc/packages/fcl-res/src/groupcursorresource.pp --descr=../fpcsrc/packages/fcl-res/xml/groupcursorresource.xml --input=../fpcsrc/packages/fcl-res/src/stringtableresource.pp --descr=../fpcsrc/packages/fcl-res/xml/stringtableresource.xml --input=../fpcsrc/packages/fcl-res/src/versionconsts.pp --descr=../fpcsrc/packages/fcl-res/xml/versionconsts.xml --input=../fpcsrc/packages/fcl-res/src/versiontypes.pp --descr=../fpcsrc/packages/fcl-res/xml/versiontypes.xml --input=../fpcsrc/packages/fcl-res/src/versionresource.pp --descr=../fpcsrc/packages/fcl-res/xml/versionresource.xml --input=../fpcsrc/packages/fcl-res/src/cofftypes.pp --descr=../fpcsrc/packages/fcl-res/xml/cofftypes.xml --input=../fpcsrc/packages/fcl-res/src/coffreader.pp --descr=../fpcsrc/packages/fcl-res/xml/coffreader.xml --input=../fpcsrc/packages/fcl-res/src/coffwriter.pp --descr=../fpcsrc/packages/fcl-res/xml/coffwriter.xml --input=../fpcsrc/packages/fcl-res/src/winpeimagereader.pp --descr=../fpcsrc/packages/fcl-res/xml/winpeimagereader.xml --input=../fpcsrc/packages/fcl-res/src/elfconsts.pp --descr=../fpcsrc/packages/fcl-res/xml/elfconsts.xml --input=../fpcsrc/packages/fcl-res/src/elfreader.pp --descr=../fpcsrc/packages/fcl-res/xml/elfreader.xml --input=../fpcsrc/packages/fcl-res/src/elfwriter.pp --descr=../fpcsrc/packages/fcl-res/xml/elfwriter.xml --input=../fpcsrc/packages/fcl-res/src/machotypes.pp --descr=../fpcsrc/packages/fcl-res/xml/machotypes.xml --input=../fpcsrc/packages/fcl-res/src/machoreader.pp --descr=../fpcsrc/packages/fcl-res/xml/machoreader.xml --input=../fpcsrc/packages/fcl-res/src/machowriter.pp --descr=../fpcsrc/packages/fcl-res/xml/machowriter.xml --input=../fpcsrc/packages/fcl-res/src/externaltypes.pp --descr=../fpcsrc/packages/fcl-res/xml/externaltypes.xml --input=../fpcsrc/packages/fcl-res/src/externalreader.pp --descr=../fpcsrc/packages/fcl-res/xml/externalreader.xml --input=../fpcsrc/packages/fcl-res/src/externalwriter.pp --descr=../fpcsrc/packages/fcl-res/xml/externalwriter.xml --input=../fpcsrc/packages/fcl-res/src/dfmreader.pp --descr=../fpcsrc/packages/fcl-res/xml/dfmreader.xml --format=html --output=fclres
FPDoc - Free Pascal Documentation Tool
Version 3.0.4 [2019/01/16]
(c) 2000 - 2003 Areca Systems GmbH / Sebastian Guenther, sg@freepascal.org
(c) 2005 - 2012 various FPC contributors

Exception at 000000000047BA16: EInOutError:
File not found: fcl.xct.

Abou Al Montacir

2019-11-23 14:21

manager   ~0119450

OK the stop-on-parser-error flag is set in the RTL project:
$grep -nr stop-on-parser-error
fcl-project.xml:9: <option name="stop-on-parser-error" value="false"/>
fpdoc.tex:928: <option name="stop-on-parser-error" value="false"/>
rtl-project.xml:9: <option name="stop-on-parser-error" value="false"/>

However this shall not prevent the exit code to be reported as 1 instead of 0.
In the above example I got:
$ # the long command line was skipped to ease reading
FPDoc - Free Pascal Documentation Tool
Version 3.0.4 [2019/01/16]
(c) 2000 - 2003 Areca Systems GmbH / Sebastian Guenther, sg@freepascal.org
(c) 2005 - 2012 various FPC contributors

Exception at 000000000047BA16: EInOutError:
File not found: fcl.xct.

$echo $?
0

So the issue is still valid even if the analysis I provided was wrong. Can we reopen the ticket please?

Michael Van Canneyt

2019-11-23 14:35

administrator   ~0119451

Implemented a fix in rev 43563

Abou Al Montacir

2019-11-23 15:05

manager   ~0119452

I can confirm this is now fixed, thanks.

FPDoc - Free Pascal Documentation Tool
Version 3.0.4 [2019/01/24]
(c) 2000 - 2003 Areca Systems GmbH / Sebastian Guenther, sg@freepascal.org
(c) 2005 - 2012 various FPC contributors

Exception at 000000000047F415: EInOutError:
File not found: rtl.xct.
make[2]: *** [Makefile:2729: fcl.chk] Error 1

Issue History

Date Modified Username Field Change
2019-11-23 12:48 Abou Al Montacir New Issue
2019-11-23 12:52 Michael Van Canneyt Assigned To => Michael Van Canneyt
2019-11-23 12:52 Michael Van Canneyt Status new => assigned
2019-11-23 13:03 Michael Van Canneyt Status assigned => resolved
2019-11-23 13:03 Michael Van Canneyt Resolution open => no change required
2019-11-23 13:03 Michael Van Canneyt FPCTarget => -
2019-11-23 13:03 Michael Van Canneyt Note Added: 0119447
2019-11-23 13:05 Michael Van Canneyt Note Edited: 0119447 View Revisions
2019-11-23 13:59 Abou Al Montacir Note Added: 0119449
2019-11-23 14:21 Abou Al Montacir Note Added: 0119450
2019-11-23 14:35 Michael Van Canneyt Note Added: 0119451
2019-11-23 14:35 Michael Van Canneyt Resolution no change required => fixed
2019-11-23 14:35 Michael Van Canneyt Fixed in Version => 3.3.1
2019-11-23 14:35 Michael Van Canneyt Fixed in Revision => 43563
2019-11-23 14:35 Michael Van Canneyt FPCTarget - => 3.2.0
2019-11-23 15:05 Abou Al Montacir Note Added: 0119452