[ReOpened][SOLVED] Serious FpOleBasic.pas error/bug lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- JD · 2012-07-03 21:46 Hi there everyone, For some time now, about 25% of the time, whenever I compile one of my projects that uses FpSpreadsheet I get the error below and compilation fails FpSpreadsheet\fpolebasic.pas(65,3) Fatal: Internal error 200305057 The error occurs on the line in bold below:  AOLEDocument.Stream.Position:=0; //Ensures it is in the begining. The procedure that causes the problem WriteOLEFile is as shown below Code: [Select]procedure TOLEStorage.WriteOLEFile(AFileName: string;   AOLEDocument: TOLEDocument; const AOverwriteExisting: Boolean;   const AStreamName: UTF8String); var   RealFile: TFileStream;   fsOLE: TVirtualLayer_OLE;   OLEStream: TStream;   VLAbsolutePath: UTF8String; begin   VLAbsolutePath:='/'+AStreamName; //Virtual layer always use absolute paths.   if not AOverwriteExisting and FileExists(AFileName) then begin       Raise EStreamError.Createfmt('File already exists "%s"',[AFileName]);   end;   RealFile:=TFileStream.Create(AFileName,fmCreate);   fsOLE:=TVirtualLayer_OLE.Create(RealFile);   fsOLE.Format(); //Initialize and format the OLE container.   OLEStream:=fsOLE.CreateStream(VLAbsolutePath,fmCreate);   AOLEDocument.Stream.Position:=0; //Ensures it is in the begining.   OLEStream.CopyFrom(AOLEDocument.Stream,AOLEDocument.Stream.Size);   OLEStream.Free;   fsOLE.Free;   RealFile.Free; end; Has anyone had a similar experience and does anyone know how I can fix it? JD ---------------------------------------------------------------------- Leledumbo · 2012-07-04 04:22 Please report it, internal error could be said as "error that should never happen". ---------------------------------------------------------------------- felipemdc · 2012-07-04 06:06 Internal errors are compiler errors. Please open a bug report for the compiler. Which compiler version are you using? You could try using another version. ---------------------------------------------------------------------- marcov · 2012-07-04 08:52 Leledumbo: first search for the number of the IE  in the bug database of FPC with all filters off (so that you also see resolved and closed items) Marked as fixed in 2.7.1: http://bugs.freepascal.org/view.php?id=21914 ---------------------------------------------------------------------- JD · 2012-07-04 09:41 Quote from: felipemdc on July 04, 2012, 08:06:55 amInternal errors are compiler errors. Please open a bug report for the compiler. Which compiler version are you using? You could try using another version. Sorry about that. I forgot. I'm using Lazarus 1.1 svn 37469 Win32/FPC 2.6.0 on Windows Vista. ---------------------------------------------------------------------- JD · 2012-07-04 09:47 Quote from: marcov on July 04, 2012, 10:52:11 amLeledumbo: first search for the number of the IE  in the bug database of FPC with all filters off (so that you also see resolved and closed items) Marked as fixed in 2.7.1: http://bugs.freepascal.org/view.php?id=21914 I don't want to move to FPC version 2.7.1 yet because some of my large collection of installed components may no longer work! This has been the case in the past whenever I use the "non-release" FPC version. ---------------------------------------------------------------------- Leledumbo · 2012-07-04 13:08 QuoteI don't want to move to FPC version 2.7.1 yet because some of my large collection of installed components may no longer work! This has been the case in the past whenever I use the "non-release" FPC version.Again: report and wait for fix, it's just the same case with release version actually. Try 2.6.1 (fixes branch of 2.6.0?) if you're afraid with 2.7.1, there will NEVER be 2.6.0 with the fix applied. ---------------------------------------------------------------------- BigChimp · 2012-07-05 10:00 I noticed you reported in the bug report you were running FPC 2.6.0. 2.6.0 receives no patches/improvements/changes at all. It could be that a fix has been implemented (e.g. the fix in 2.7.1 that Marco talked about) and backported/applied to 2.6.1 I would strongly suggest getting a Lazarus version with FPC 2.6.1 (using e.g. a snapshot, or a separate install using fpcup or manual subversion) and testing with that. The devs are quite probably going to ask you to do that anyway to confirm the bug is still present. (An aside: I've been using the 2.6.1 version a while now and like the bug fixes compared to 2.6.0... without any new problems... knock on wood.) Also, even though the problem is not reproducible 100% of the time, it might be helpful to include a minimal test program if that is possible (and still demonstrates the bug)... ---------------------------------------------------------------------- JD · 2012-07-05 10:36 @Leledumbo It is not a question of fear. It is more a question of having to rewrite perfectly working code in projects that are so close to delivery date and just before the summer holidays.  @BigChimp Yes I did submit a bug report; simply because what I suspected with the 2.7.1 version came to pass. That is, some of my major components, including the indispensible Virtual TreeView, refused to compile. I was hoping that perhaps a workaround could be found by rewriting the code in the fpolebasic.pas file.  I've downloaded the 2.6.1 version but I've not tested it yet. I hope it will solve the problem without forcing me to make major changes in my setup. Thanks, JD ---------------------------------------------------------------------- BigChimp · 2012-07-05 11:54 @JD: to clarify: my point was not about the reason for filing the bug; my point is you shouldn't have used 2.6.0 to make that report: any fix that will be performed will never get in 2.6.0 so you'll have to move to 2.6.1 anyway. (Ok, assuming the problem/fix is in the FPC side of things, but given that it is an internal error, that seems very likely) Let's hope 2.6.1 Just Works for you... ---------------------------------------------------------------------- JD · 2012-07-05 13:10 Quote from: BigChimp on July 05, 2012, 01:54:47 pm@JD: to clarify: my point was not about the reason for filing the bug; my point is you shouldn't have used 2.6.0 to make that report: any fix that will be performed will never get in 2.6.0 so you'll have to move to 2.6.1 anyway. (Ok, assuming the problem/fix is in the FPC side of things, but given that it is an internal error, that seems very likely) Let's hope 2.6.1 Just Works for you... Well I just tested Laz 1.1 svn 37865/FPC 2.6.1 Win32 and unfortunately it did not work. However, I patched up the fpolebasic.pas file according to the suggestion of Jose Méjuto http://bugs.freepascal.org/view.php?id=22370 and I was able to compile the project. The only downside was that I had to remove Virtual TreeView from the project because it cannot compile using 2.6.1 (same scenario with 2.7.1).  I'll be needing LuizAmerico's help with that since he's the maintainer of the package. Thanks to all for your suggestions. JD ---------------------------------------------------------------------- felipemdc · 2012-07-07 05:28 I commited the work around from the bug report, so it should work OK now if you svn update your fpspreadsheet and go back to FPC 2.6.0 ---------------------------------------------------------------------- marcov · 2012-07-09 12:08 Quote from: BigChimp on July 05, 2012, 12:00:47 pmI noticed you reported in the bug report you were running FPC 2.6.0. 2.6.0 receives no patches/improvements/changes at all. It could be that a fix has been implemented (e.g. the fix in 2.7.1 that Marco talked about) and backported/applied to 2.6.1 Compiler fixes are not as often merged to fixes as RTL/packages fixes, because they are more interweaved. ---------------------------------------------------------------------- BigChimp · 2012-07-09 12:18 There still is a difference between not at all and not as often, is there? Then I fail to see why my post needs clarification? Anyway, looking at Felipe's post, the issue has actually been fixed already - even for FPC 2.6.0. ---------------------------------------------------------------------- BigChimp · 2012-09-12 12:29 Unfortunately, I'm running into the same internal error 200305057 with the fpspreadsheet svn code (r2475, dated 2012-07-05) in another position: Code: [Select]  // work around code for the bug 22370   tmpStream:=AOLEDocument.Stream;   tmpStream.Position:=0; //Ensures it is in the begining.   //previous code: AOLEDocument.Stream.Position:=0; //Ensures it is in the begining.   OLEStream.CopyFrom(AOLEDocument.Stream,AOLEDocument.Stream.Size); //<= Fatal: internal error 200305057 Both with Laz 1.0+FPC 2.6.0 and Laz trunk+FPC 2.6.1 (r22356) Edit: also with Laz trunk+FPC trunk (r22340) Edit: source code that demonstrates the problem can be downloaded via https://bitbucket.org/reiniero/postcode/downloads/fpspreadsheetinterna lerror.zip (which is the source code of commit 4e331a9e4015) Edit: Tried to create a simple Laz application that replicates it, but it doesn't seem to trigger the error: See simple Lazarus application attached to bug report. ---------------------------------------------------------------------- BigChimp · 2012-09-13 08:12 Error seems to depend on -O2 or higher. Reported as http://bugs.freepascal.org/view.php?id=22869 ---------------------------------------------------------------------- JD · 2012-09-13 09:02 I had forgotten about this because it seemed to go away since I moved to FPC 2.6.1. Is this going to be an issue also for FPC 2.6.1? ---------------------------------------------------------------------- BigChimp · 2012-09-13 09:10 Yes, tested on 2.6.0, 2.6.1 and trunk; see bug report ---------------------------------------------------------------------- BigChimp · 2012-09-13 14:03 Meanwhile, Jonas Maebe fixed FPC 2.7.1/trunk, hopefully fixing this bug (FPC test case compiles ok now; couldn't test Lazarus test case because Lazarus+FPC 2.7.1 is broken right now). Thanks, Jonas! It apparently also fixes the original bug so perhaps the workaround in fpspreadsheet is no longer needed. Have requested a backport to FPC 2.6.1 on the mailing list. Thanks, BigChimp ---------------------------------------------------------------------- JD · 2012-09-19 10:14 Quote from: BigChimp on September 13, 2012, 04:03:53 pmMeanwhile, Jonas Maebe fixed FPC 2.7.1/trunk, hopefully fixing this bug (FPC test case compiles ok now; couldn't test Lazarus test case because Lazarus+FPC 2.7.1 is broken right now). Thanks, Jonas! It apparently also fixes the original bug so perhaps the workaround in fpspreadsheet is no longer needed. Have requested a backport to FPC 2.6.1 on the mailing list. Thanks, BigChimp The error is back again with a bang! When will the backport to FPC 2.6.1 be ready? ---------------------------------------------------------------------- BigChimp · 2012-09-22 12:12 Just read on the mailing list it is in FPC 2.6.1 revision 22436. ---------------------------------------------------------------------- JD · 2012-09-22 14:16 Quote from: BigChimp on September 22, 2012, 02:12:19 pmJust read on the mailing list it is in FPC 2.6.1 revision 22436. Can you kindly give me a link to where I can download it? Thanks a million. ---------------------------------------------------------------------- BigChimp · 2012-09-22 14:28 Ehm? It's svn so it should probably appear in a snapshot tomorrow (or later).. Alternatively: http://wiki.lazarus.freepascal.org/Installing_Lazarus#Compiling.2Finst alling_FPC_and_Lazarus_from_Sources_of_SVN_.28Win32.29 or using fpcup: https://bitbucket.org/reiniero/fpcup/downloads