View Issue Details

IDProjectCategoryView StatusLast Update
0023703LazarusIDEpublic2013-12-21 17:53
ReporterMark Morgan LloydAssigned ToMartin Friebe 
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionfixed 
Product Version1.0.4Product Build 
Target VersionFixed in Version1.4 
Summary0023703: On SPARC, crash at startup
DescriptionUsing either 2.6.0 or 2.6.1, Lazarus trunk (r39901) and 1.04 crash at startup on SPARC Linux (Debian "Lenny").

Both versions worked until recently, but I haven't found the inflection point yet. I've not checked other platforms such as PPC and ARM.
Additional InformationNOTE: help options config file not found - using defaults

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xf7fbfb10 (LWP 3352)]
0x00037518 in _$SYSTEM$_Ll6894 () at /usr/local/src/fpc/fpcbuild-2.6.0/fpcsrc/rtl/inc/dynarr.inc:160
160 elesize:=psizeint(ti)^;
(gdb) bt
#0 0x00037518 in _$SYSTEM$_Ll6894 () at /usr/local/src/fpc/fpcbuild-2.6.0/fpcsrc/rtl/inc/dynarr.inc:160
0000001 0x0094d9a0 in TLAZSYNEDITNESTEDFOLDSLIST__CLEAR (this=0xf5ae62a0) at syneditfoldedview.pp:2874
0000002 0x0094fccc in TLAZSYNEDITNESTEDFOLDSLIST__SETFOLDFLAGS (AVALUE=[SFBINCLUDEDISABLED], this=0xf5ae62a0) at syneditfoldedview.pp:3224
0000003 0x00b8f960 in TIDESYNEDITOR__SRCSYNCARETCHANGED (SENDER=0xf5c83040, this=0xf5acddd0) at sourcesyneditor.pas:814
0000004 0x00162718 in TMETHODLIST__CALLNOTIFYEVENTS (SENDER=0xf5c83040, this=0xf6040cc0) at lazmethodlist.pas:163
0000005 0x009874fc in TSYNEDITCARET__DOUNLOCK (this=0xf5c83040) at syneditpointclasses.pas:701
0000006 0x00986df4 in TSYNEDITPOINTBASE__UNLOCK (this=0xf5c83040) at syneditpointclasses.pas:642
0000007 0x009883f0 in TSYNEDITCARET__INTERNALSETLINECHARPOS (NEWLINE=1, NEWCHARPOS=1, UPDFLAGS=[SCUCHANGEDX..SCUCHANGEDY], this=0xf5c83040)
    at syneditpointclasses.pas:910
0000008 0x009859d0 in TSYNEDITBASECARET__SETLINECHARPOS (AVALUE={X = 1, Y = 1}, this=0xf5c83040) at syneditpointclasses.pas:445
0000009 0x0091f3a0 in TCUSTOMSYNEDIT__SETCARETXY (VALUE={X = 1, Y = 1}, this=0xf5acddd0) at synedit.pp:4074
0000010 0x00859c00 in TLAZSOURCEFILEMANAGER__NEWFILE (NEWFILEDESCRIPTOR=0xf60c8fa0, NEWFILENAME=0xf6080648 'unit1.pas', NEWSOURCE=0x0,
    NEWFLAGS=[NFISPARTOFPROJECT, NFOPENINEDITOR, NFCREATEDEFAULTSRC], NEWOWNER=0x0, this=0xf60408d0) at sourcefilemanager.pas:567
0000011 0x000af9c0 in TMAINIDE__DONEWFILE (NEWFILEDESCRIPTOR=0xf60c8fa0, NEWFILENAME=0xf6080648 'unit1.pas', NEWSOURCE=0x0,
    NEWFLAGS=[NFISPARTOFPROJECT, NFOPENINEDITOR, NFCREATEDEFAULTSRC], NEWOWNER=0x0, this=0xf69781a0) at main.pp:5444
0000012 0x0051e4d8 in TLAZIDEINTERFACE__DONEWEDITORFILE (NEWFILEDESCRIPTOR=0xf60c8fa0, NEWFILENAME=0xf6080648 'unit1.pas', NEWSOURCE=0x0,
    NEWFLAGS=[NFISPARTOFPROJECT, NFOPENINEDITOR, NFCREATEDEFAULTSRC], this=0xf69781a0) at lazideintf.pas:458
0000013 0x0057af6c in TPROJECTAPPLICATIONDESCRIPTOR__CREATESTARTFILES (APROJECT=0xf5f6c1c0, this=0xf6077b00) at projectdefs.pas:1324
0000014 0x0085fcf8 in TLAZSOURCEFILEMANAGER__INITNEWPROJECT (PROJECTDESC=0xf6077b00, this=0xf60408d0) at sourcefilemanager.pas:1704
0000015 0x000b58c8 in TMAINIDE__DONEWPROJECT (PROJECTDESC=0xf6077b00, this=0xf69781a0) at main.pp:6504
0000016 0x0009e49c in TMAINIDE__SETUPSTARTPROJECT (this=0xf69781a0) at main.pp:2204
0000017 0x00099f1c in TMAINIDE__STARTIDE (this=0xf69781a0) at main.pp:1460
0000018 0x00022140 in main () at lazarus.pp:111
(gdb)
TagsNo tags attached.
Fixed in Revision43551
LazTarget1.2
WidgetsetGTK 2
Attached Files
  • synedit_tests.xml (13,740 bytes)
  • synedit_tests_ppc.xml (11,988 bytes)
  • foldtestdata.diff (2,150 bytes)
    Index: components/synedit/test/testfoldedview.pas
    ===================================================================
    --- components/synedit/test/testfoldedview.pas	(revision 43544)
    +++ components/synedit/test/testfoldedview.pas	(working copy)
    @@ -1614,7 +1614,11 @@
       //DebugLn(MyDbg(FoldedView.GetFoldDescription(0,1,-1,-1, False, True)));
       //DebugLn(MyDbg(FoldedView.GetFoldDescription(0,1,-1,-1, True,  True)));
       TestCompareString('FoldDesc (NOT txt / NOT ext)',
    +{$ifdef ENDIAN_LITTLE }
                         #$00#$00#$00#$00#$00#$00#$00#$00#$07#$00#$00#$00#$04#$00#$00#$00#$04#$00#$00#$00#$04#$00#$00#$00#$0A#$00#$00#$00#$04#$00#$00#$00#$02#$00#$00#$00#$00#$00#$00#$00#$05#$00#$00#$00#$04#$00#$00#$00#$00#$00#$00#$00#$03#$00#$00#$00#$01#$00#$00#$00#$02#$00#$00#$00,
    +{$else                }
    +                    #$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$07#$00#$00#$00#$04#$00#$00#$00#$04#$00#$00#$00#$04#$00#$00#$00#$0A#$00#$00#$00#$04#$00#$00#$00#$02#$00#$00#$00#$00#$00#$00#$00#$05#$00#$00#$00#$04#$00#$00#$00#$00#$00#$00#$00#$03#$00#$00#$00#$01#$00#$00#$00#$02,
    +{$endif ENDIAN_LITTLE }
                         FoldedView.GetFoldDescription(0,1,-1,-1, False, False)
                        );
       TestCompareString('FoldDesc (txt / NOT ext)', ' TA004 T12025',
    @@ -1622,7 +1626,11 @@
                        );
       // TODO: Extended is not yet implemented
       //TestCompareString('FoldDesc (NOT txt / ext)',
    +{$ifdef ENDIAN_LITTLE }
       //                  #$00#$00#$00#$00#$00#$00#$00#$00#$07#$00#$00#$00#$04#$00#$00#$00#$00#$00#$00#$00#$03#$00#$00#$00#$0A#$00#$00#$00#$02#$00#$00#$00#$00#$00#$00#$00#$05#$00#$00#$00#$04#$00#$00#$00#$00#$00#$00#$00#$03#$00#$00#$00#$01#$00#$00#$00,
    +{$else                }
    +  //                  #$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$07#$00#$00#$00#$04#$00#$00#$00#$00#$00#$00#$00#$03#$00#$00#$00#$0A#$00#$00#$00#$02#$00#$00#$00#$00#$00#$00#$00#$05#$00#$00#$00#$04#$00#$00#$00#$00#$00#$00#$00#$03#$00#$00#$00#$01,
    +{$endif ENDIAN_LITTLE }
       //                  FoldedView.GetFoldDescription(0,1,-1,-1, False, True)
       //                 );
       //TestCompareString('FoldDesc (txt / ext)', ' TA004 T12025',
    
    foldtestdata.diff (2,150 bytes)

Activities

Mark Morgan Lloyd

2013-08-07 11:25

reporter   ~0069287

This doesn't affect PPC, I've not tested ARM (might affect chips which are alignment-sensitive). I'm retesting trunk against FPC 2.7.1 to get an up-to-date backtrace.

Mark Morgan Lloyd

2013-11-23 19:20

reporter   ~0071523

This is still a problem on trunk, with a backtrace similar to the above.

Martin Friebe

2013-11-24 16:03

manager   ~0071543

Last edited: 2013-11-24 16:17

View 2 revisions

The problem happens in SetLength (array,0)

I can see 2 possibilities:

1) accessing a none existing array. Since the array is a field and objects are zeroed on creation, it would mean a none existing array. (all the "this" in the trace look reasonable)

break in 3rd line of

procedure TIDESynEditor.SrcSynCaretChanged(Sender: TObject);

line 1368
[O] FSrcSynCaretChangedLock := True;
     try

Check the objects
Also check the "instance type, what class are they really? Hints will show that, watches have a checkbox)

 self
 TextView
 TextView.Flines
 TextView.FFoldProvider
 TextView.FFoldProvider
 TextView.FFoldProvider.FHighLighter

step to the line
      List := TextView.FoldProvider.NestedFoldsList;
step into
function TSynEditFoldProvider.GetNestedFoldsList: TLazSynEditNestedFoldsList;
begin
  if FNestedFoldsList = nil then
    FNestedFoldsList := TLazSynEditNestedFoldsList.Create(Self);
  Result := FNestedFoldsList;
end;

First run, it should create the list.

Continue stepping *over* (next 6 lines)
You can step into, to ensure it crashes on setlength, in clear.

The crash should happen in one of those lines. probably
      List.FoldFlags := [sfbIncludeDisabled];

The crash may not happen on the first time the code runs.
On the 2nd check that the list is still intact. Add a breakpoint to its destructor. (Not sure there may be more than one list)

If any object above looked like a dangling pointer to trash, then that needs to be investigated.

Otherwise see (2)

2)
If it crashed on on a valid list, then maybe fpc produced bad RTTI for the type of the array element? (I saw a similar issue earlier this year 0024439 )

0x00037518 in _$SYSTEM$_Ll6894 () at /usr/local/src/fpc/fpcbuild-2.6.0/fpcsrc/rtl/inc/dynarr.inc:160
160 elesize:=psizeint(ti)^;
(gdb) bt

Is in the RTTI code.

Martin Friebe

2013-11-24 16:07

manager   ~0071544

Try creating an array of
  TLazSynEditNestedFoldsListEntry = record
    FFLags: set of (nfeHasHNode, nfeMaxPrevReached);
    FGroupEndLevels: Array of Integer;
    LineIdx: TLineIdx; // = type integer
    HNode: TSynFoldNodeInfo;
    PrevNodeAtSameLevel: array of TLazSynEditNestedFoldsListEntry;
  end;


And also set a none 0 len to some of the nested.

Then SetLength 0 to the outer

Mark Morgan Lloyd

2013-11-24 22:20

reporter   ~0071562

Focusing first on your 16:07, which I think addresses your (2), are the FFlags..HNode fields needed? Leaving them out to avoid having to work out the imports and testing with

procedure TForm1.Button1Click(Sender: TObject);

var i: integer;

begin
  for i := 1 to 5 do begin
    SetLength(testArray, i);
    SetLength(testArray[i - 1].PrevNodeAtSameLevel, i)
  end
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  SetLength(testArray, 0)
end;

does not produce an error. Note that there is no error on PPC Linux, this combination would normally suggest an alignment issue rather than a dangling pointer or similar.

Mark Morgan Lloyd

2013-11-25 11:07

reporter   ~0071574

No error with explicit imports and the full data structure.

uses
  synedittypes, // for TLineIdx
  synedithighlighterfoldbase; // for TSynFoldNodeInfo

SPARC running Debian "Lenny", FPC 2.6.2, Lazarus trunk. Interleaving the test program and the IDE confirms that the IDE is still unhappy.

Martin Friebe

2013-11-25 13:33

manager   ~0071582

I also do not think it is a dangling pointer.

Program received signal SIGSEGV, Segmentation fault.
160 elesize:=psizeint(ti)^

Points to a nil pointer in type info. I do not know if that can depend on actual app data. (the type is compile time, and RTTi is done by the compiler)

Anyway, from the limited understanding I have this is either a compiler issue, or it could be a random memory access anywhere else, not at all related to the code.

If it is indeed in the calling code, I need some clue from debugging, which object or variable contains invalid data. I can not reproduce it myself.

Maybe a newer compiler will solve it?

Mark Morgan Lloyd

2013-11-25 14:11

reporter   ~0071584

I'll try with trunk FPC and trunk Lazarus.

Since compilation etc. isn't exactly instantaneous on this kit, if anybody thinks that's not a viable combination please warn me ASAP.

Mark Morgan Lloyd

2013-11-27 10:57

reporter   ~0071640

Lazarus trunk doesn't compile with FPC 2.7.1 at present on SPARC, I've not checked other platforms (e.g. PPC).

Lazarus trunk compiled with 2.6.2 appears functional but still gives the reported problem.

That leaves me in the position of having to get to grips with gdb, and the application thereof to the innards of Lazarus and Synedit.

In the interim, I think I'll try a binary chop to see if I can track down what trunk revision triggers the issue.

Even at trunk, lazbuild can still generally produce a working program- even with a synedit component in use.

Martin Friebe

2013-11-27 14:15

manager   ~0071646

I added a nil check in rev 43486. I do not believe it is related, but anyway

Mark Morgan Lloyd

2013-11-27 15:51

reporter   ~0071648

No change unfortunately. I'll try to track down the responsible change, since that's something I can do comparatively "hands-off".

Mark Morgan Lloyd

2013-11-28 15:02

reporter   ~0071680

What I can say so far is that trunk revision 38506 appears to run fine, while 38507 crashes during startup. The issue appears to be the default state of the info displayed at the top of the editing window.

Reverting that patch, current trunk is significantly more robust: it runs, even though there are internal exceptions that GDB is able to pick up. Pending your (Martin) thoughts, I might try to work forwards from 38k to see what else I can pick up.

I don't see anything in the GUI to disable the top-info display, and even if there were these early-stage crashes kill the IDE before it's had an opportunity to save any state to disc.

Martin Friebe

2013-11-28 15:11

manager   ~0071681

Last edited: 2013-11-28 15:13

View 2 revisions

This just enables the feature.

Before that the feature was off by default. If you use 38506 or earlier, and switch the feature on in the config, and then restart the IDE, what happens?

Tools / Options / Editor / Display > Show Class/Proc Hint

Mark Morgan Lloyd

2013-11-28 17:56

reporter   ~0071687

> This just enables the feature.
>
> Before that the feature was off by default.

Yes, that I worked out.

> If you use 38506 or earlier, and switch the feature on in the config, and
> then restart the IDE, what happens?
>
> Tools / Options / Editor / Display > Show Class/Proc Hint

That's the setting I couldn't find. Recompile 38506, wipe ~/.lazarus. Run, noting that there's a blank project. Tick checkbox as above, hit OK and get an immediate

0x00036738 in _$SYSTEM$_Ll6894 () at /usr/local/src/fpc/fpcbuild-2.6.0/fpcsrc/rtl/inc/dynarr.inc:160
160 elesize:=psizeint(ti)^;
(gdb) bt
#0 0x00036738 in _$SYSTEM$_Ll6894 () at /usr/local/src/fpc/fpcbuild-2.6.0/fpcsrc/rtl/inc/dynarr.inc:160
0000001 0x0092c450 in TLAZSYNEDITNESTEDFOLDSLIST__CLEAR (this=0xf5f7eb50) at syneditfoldedview.pp:2871
0000002 0x0092e674 in TLAZSYNEDITNESTEDFOLDSLIST__SETFOLDFLAGS (AVALUE=[SFBINCLUDEDISABLED], this=0xf5f7eb50)
    at syneditfoldedview.pp:3210
0000003 0x00b46dd4 in TIDESYNEDITOR__SRCSYNCARETCHANGED (SENDER=0x0, this=0xf58338a0) at sourcesyneditor.pas:650
0000004 0x00b474e8 in TIDESYNEDITOR__SETSHOWTOPINFO (AVALUE=true, this=0xf58338a0) at sourcesyneditor.pas:742
0000005 0x006dd948 in TEDITOROPTIONS__GETSYNEDITSETTINGS (ASYNEDIT=0xf58338a0, SIMILAREDIT=0x0, this=0xf6584120)
    at editoroptions.pp:4702
0000006 0x0069591c in TSOURCEEDITOR__REFRESHEDITORSETTINGS (this=0xf58491a0) at sourceeditor.pp:3988
0000007 0x006a96a8 in TSOURCENOTEBOOK__RELOADEDITOROPTIONS (this=0xf5832f60) at sourceeditor.pp:7766
0000008 0x006aeccc in TSOURCEEDITORMANAGER__RELOADEDITOROPTIONS (this=0xf68cc020) at sourceeditor.pp:9092
0000009 0x000ab464 in TMAINIDE__DOEDITOROPTIONSAFTERWRITE (SENDER=0xf6584120, RESTORE=false, this=0xf668c360) at main.pp:5138
0000010 0x00528b14 in TABSTRACTIDEOPTIONS__DOAFTERWRITE (RESTORE=false, this=0xf6584120) at ideoptionsintf.pas:793
0000011 0x006da558 in TEDITOROPTIONS__DOAFTERWRITE (RESTORE=false, this=0xf6584120) at editoroptions.pp:4179
0000012 0x00784eac in TIDEOPTIONSDIALOG__WRITEALL (RESTORE=false, this=0xf612fc00) at ideoptionsdlg.pas:360
0000013 0x000aaaac in TMAINIDE__DOOPENIDEOPTIONS (AEDITOR=<incomplete type>, ACAPTION=0x0, AOPTIONSFILTER=0xf5aecc10,
    ASETTINGS=[], highAOPTIONSFILTER=-1, this=0xf668c360) at main.pp:5008
0000014 0x00526908 in TLAZIDEINTERFACE__DOOPENIDEOPTIONS (AEDITOR=<incomplete type>, ACAPTION=0x0, this=0xf668c360)
    at lazideintf.pas:463
0000015 0x000aa2b4 in TMAINIDE__MNUENVGENERALOPTIONSCLICKED (SENDER=0xf5ae23f0, this=0xf668c360) at main.pp:4917
0000016 0x0051fed8 in TIDEMENUITEM__MENUITEMCLICK (SENDER=0xf67b4f20, this=0xf5ae23f0) at menuintf.pas:580
0000017 0x00524f08 in TIDEMENUCOMMAND__MENUITEMCLICK (SENDER=0xf67b4f20, this=0xf5ae23f0) at menuintf.pas:1655
0000018 0x002bfd34 in TMENUITEM__CLICK (this=0xf67b4f20) at ./include/menuitem.inc:83
0000019 0x002c0758 in TMENUITEM__DOCLICKED (MSG=void, this=0xf67b4f20) at ./include/menuitem.inc:278
0000020 0x000382b4 in _$SYSTEM$_Ll7225 () at /usr/local/src/fpc/fpcbuild-2.6.0/fpcsrc/rtl/inc/objpas.inc:592
0000021 0x00384200 in DELIVERMESSAGE (TARGET=0xf67b4f20, AMESSAGE=void) at lclmessageglue.pas:119
0000022 0x00338f38 in DELIVERMESSAGE (TARGET=0xf67b4f20, AMESSAGE=void) at gtk2proc.inc:3591
0000023 0x0040ec2c in GTK2MENUITEMACTIVATE (WIDGET=0x14fe8a0, DATA=0xf67b4f20) at gtk2wsmenus.pp:142
0000024 0xf76599a0 in g_cclosure_marshal_VOID__VOID () from /usr/lib/libgobject-2.0.so.0
0000025 0xf764aeb8 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
0000026 0xf76630ec in ?? () from /usr/lib/libgobject-2.0.so.0
0000027 0xf76630ec in ?? () from /usr/lib/libgobject-2.0.so.0
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Sven Barth

2013-11-29 09:10

manager   ~0071694

Which compiler version did you use? At least in 2.7.1 line 160 of dynarr.inc is not "elesize:=psizeint(ti)^"... If you used 2.7.1 then please ensure that you point GDB to the correct source files.

Regards,
Sven

Mark Morgan Lloyd

2013-11-29 09:42

reporter   ~0071695

2.6.0. When I was working back through Lazarus versions I found 39000 was OK with 2.6.2, but by the time I got to 38000 I had to revert to 2.6.0.

Martin Friebe

2013-11-29 14:28

manager   ~0071698

This is still the same error. And it looks more and more like an issue with fpc generating wrong code/data. (Just my guess)

Can you run the testcase in SynEdit/test? It also uses NestedFoldList.

The test group: TTestFoldedView.

Sven Barth

2013-11-29 16:44

manager   ~0071703

I suspect the same. Especially considering that we already had an array related bug found for Sparc (though it does not seem to be the same).

Regards,
Sven

Mark Morgan Lloyd

2013-11-29 17:36

reporter   ~0071704

Ooh shiny :-) OK, running that section of the test gives controlled failures (i.e. the whole program doesn't bomb). I'm running the entire test for good measure, and will post the XML file on completion.

Mark Morgan Lloyd

2013-11-29 18:17

reporter  

synedit_tests.xml (13,740 bytes)

Mark Morgan Lloyd

2013-11-29 18:18

reporter   ~0071705

Results attached. Generated with current trunk Lazarus and FPC 2.6.2.

Martin Friebe

2013-11-29 20:41

manager   ~0071708

None looks related to the original issue. Maybe the range check in TTestFoldedView.TestFoldEdit

Sparc is Big endian? Maybe some type cast does go wrong there.

All the test work fine on win. So there is little I can do about them now.

Mark Morgan Lloyd

2013-11-29 22:38

reporter  

synedit_tests_ppc.xml (11,988 bytes)

Mark Morgan Lloyd

2013-11-29 22:39

reporter   ~0071710

> Sparc is Big endian? Maybe some type cast does go wrong there.

As is PPC, and while the IDE appears to work I find that some of the tests fail (results uploaded).

Martin Friebe

2013-11-29 23:32

manager   ~0071711

Just checked:

TTestFoldedView.TestFoldStateDesc: FoldDesc (NOT txt / NOT ext)
This is endian. But it will not affect operation. The value is copied back to the structure (record/integer) and should be fine. Only an issue, if you share a clipboard between machines with different endianess. (this is used, if copying text with fold info, and pasting it back).

Searchrange; HideSingleMatch=False NOT Found after lastline(CNT) expected:
Not sure, maybe related to differences in clientrect.

---
That leaves the range checks.

Best point to start, is to got traces, and which value is out of range.
(If you debug and if you debug in the IDE, you can use the history window, and export data)

Mark Morgan Lloyd

2013-12-02 10:17

reporter   ~0071724

I think that in practice I might have to work with around 38506 to find this, since there are various other exceptions in current trunk.

Can anybody say where in ~/.lazarus the equivalent of

> Tools / Options / Editor / Display > Show Class/Proc Hint

is stored?

Martin Friebe

2013-12-03 17:58

manager   ~0071749

editoroptions.xml

<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
  <EditorOptions>
    <Misc TopInfoView="True"/>

If you run a IDE with the default=true, then the entry is removed. Older IDE will take it from there. (IIRC / Afaik)

Mark Morgan Lloyd

2013-12-04 14:42

reporter   ~0071767

Thanks Martin, noted. I'll be back :-)

Mark Morgan Lloyd

2013-12-15 19:30

reporter  

foldtestdata.diff (2,150 bytes)
Index: components/synedit/test/testfoldedview.pas
===================================================================
--- components/synedit/test/testfoldedview.pas	(revision 43544)
+++ components/synedit/test/testfoldedview.pas	(working copy)
@@ -1614,7 +1614,11 @@
   //DebugLn(MyDbg(FoldedView.GetFoldDescription(0,1,-1,-1, False, True)));
   //DebugLn(MyDbg(FoldedView.GetFoldDescription(0,1,-1,-1, True,  True)));
   TestCompareString('FoldDesc (NOT txt / NOT ext)',
+{$ifdef ENDIAN_LITTLE }
                     #$00#$00#$00#$00#$00#$00#$00#$00#$07#$00#$00#$00#$04#$00#$00#$00#$04#$00#$00#$00#$04#$00#$00#$00#$0A#$00#$00#$00#$04#$00#$00#$00#$02#$00#$00#$00#$00#$00#$00#$00#$05#$00#$00#$00#$04#$00#$00#$00#$00#$00#$00#$00#$03#$00#$00#$00#$01#$00#$00#$00#$02#$00#$00#$00,
+{$else                }
+                    #$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$07#$00#$00#$00#$04#$00#$00#$00#$04#$00#$00#$00#$04#$00#$00#$00#$0A#$00#$00#$00#$04#$00#$00#$00#$02#$00#$00#$00#$00#$00#$00#$00#$05#$00#$00#$00#$04#$00#$00#$00#$00#$00#$00#$00#$03#$00#$00#$00#$01#$00#$00#$00#$02,
+{$endif ENDIAN_LITTLE }
                     FoldedView.GetFoldDescription(0,1,-1,-1, False, False)
                    );
   TestCompareString('FoldDesc (txt / NOT ext)', ' TA004 T12025',
@@ -1622,7 +1626,11 @@
                    );
   // TODO: Extended is not yet implemented
   //TestCompareString('FoldDesc (NOT txt / ext)',
+{$ifdef ENDIAN_LITTLE }
   //                  #$00#$00#$00#$00#$00#$00#$00#$00#$07#$00#$00#$00#$04#$00#$00#$00#$00#$00#$00#$00#$03#$00#$00#$00#$0A#$00#$00#$00#$02#$00#$00#$00#$00#$00#$00#$00#$05#$00#$00#$00#$04#$00#$00#$00#$00#$00#$00#$00#$03#$00#$00#$00#$01#$00#$00#$00,
+{$else                }
+  //                  #$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$00#$07#$00#$00#$00#$04#$00#$00#$00#$00#$00#$00#$00#$03#$00#$00#$00#$0A#$00#$00#$00#$02#$00#$00#$00#$00#$00#$00#$00#$05#$00#$00#$00#$04#$00#$00#$00#$00#$00#$00#$00#$03#$00#$00#$00#$01,
+{$endif ENDIAN_LITTLE }
   //                  FoldedView.GetFoldDescription(0,1,-1,-1, False, True)
   //                 );
   //TestCompareString('FoldDesc (txt / ext)', ' TA004 T12025',
foldtestdata.diff (2,150 bytes)

Mark Morgan Lloyd

2013-12-15 19:38

reporter   ~0071906

Patch uploaded with big-endian test data for testfoldedview.pas. That gets rid of the easiest problem, and results in a clean run on PPC.

I'm still looking at SPARC, which has two other issues (overflow in TTestSynBeautifier, range check in TTestHighlighterPas and TTestFoldedView).

Martin Friebe

2013-12-16 02:15

manager   ~0071913

Applied rev 43551, thanks

Mark Morgan Lloyd

2013-12-16 10:19

reporter   ~0071917

I worked back through the code until I could see just how much hassle making sure that endianness was consistent would be. It's a pity that there isn't a recognisable "magic number" at the start, e.g. 0x0d0a1a00.

While I'm whining... now that there's %region and %endregion, could %todo be accepted to keep the format consistent?

Martin Friebe

2013-12-16 14:01

manager   ~0071921

Then %todo must be added to the todo list plugin too. Please discuss outside this issue.

Mark Morgan Lloyd

2013-12-18 11:12

reporter   ~0071948

Almost certainly a compiler problem. I've ended up instrumenting some of the code using WriteLn, and on SPARC (but not on x86) the dec() in TSynPasSynRange.DecLastLinePasFoldFix raises a range exception when the the parameter (a smallint) is -1.

Sven Barth

2013-12-18 12:00

manager   ~0071950

Could you try to extract and minimize the problematic code so that we could have a simpler example for testing?

Regards,
Sven

Mark Morgan Lloyd

2013-12-18 12:12

reporter   ~0071951

Working on it, although due to other commitments...

This is with 2.6.0, obviously I'll check against newer versions. I'm finding building current trunk Lazarus with later compilers an issue, which is one reason why I've stuck with an older revision.

I'd add that GDB with SPARC can be tricky on account of the delay slot, which is one reason why I reverted to ye good olde WriteLn technique.

Mark Morgan Lloyd

2013-12-18 19:32

reporter   ~0071959

http://bugs.freepascal.org/view.php?id=25440 with test program. Affects FPC trunk as well as older versions.

Mark Morgan Lloyd

2013-12-19 13:17

reporter   ~0071966

The other issue appears to be a spurious overflow check (affecting integer multiplications when the result is -ve) which is present in 2.6.0 and 2.6.2 but has been fixed in 2.7.1.

Martin Friebe

2013-12-19 14:12

manager   ~0071970

If workarounds for this are added, does the initial crash go away too? If so, can this be closed?

(If so,) Depending on the workaround, they may be added in IFDEF to the Lazarus code.

Mark Morgan Lloyd

2013-12-19 14:57

reporter   ~0071972

I don't have a workaround at the moment, since the compiler error in 25440 is fairly pervasive. If somebody had a fix for that then I could have another shot building the IDE with 2.7.1, or possibly backport the fix to 2.6.2.

I believe that lazbuild is OK, but the compiler error is obviously a timebomb in anything built with it.

Martin Friebe

2013-12-19 16:38

manager   ~0071974

You could make the field normal int, for testing. It will use more memory, but should work. Or assign to a local int var ...

Mark Morgan Lloyd

2013-12-19 17:03

reporter   ~0071975

OK, I'll look at it presently but to do the job even half-decently would mean getting onto FPC trunk for the sake of the other fix. I'll be interested in any comment from the FPC team but it looks like an unambiguous code-generation issue, so I don't see why Lazarus should work around that with conditionals.

Mark Morgan Lloyd

2013-12-21 11:50

reporter   ~0071996

I believe it's fixed by the compiler patches described in 25440. I can't test the IDE until they trickle down into release code (2.6.6?), since a backport turns out to be non-trivial.

I suggest closing on the strength of that.

Maxim Ganetsky

2013-12-21 16:52

developer   ~0072001

Last edited: 2013-12-21 16:52

View 2 revisions

Resolved at reporter's request.

Mark Morgan Lloyd

2013-12-21 17:53

reporter   ~0072002

Thanks to everybody for the help.

Issue History

Date Modified Username Field Change
2013-01-20 10:25 Mark Morgan Lloyd New Issue
2013-01-20 10:25 Mark Morgan Lloyd Widgetset => GTK 2
2013-08-07 11:06 Juha Manninen LazTarget => 1.2
2013-08-07 11:25 Mark Morgan Lloyd Note Added: 0069287
2013-11-23 19:20 Mark Morgan Lloyd Note Added: 0071523
2013-11-24 16:03 Martin Friebe Note Added: 0071543
2013-11-24 16:07 Martin Friebe Note Added: 0071544
2013-11-24 16:17 Martin Friebe Note Edited: 0071543 View Revisions
2013-11-24 22:20 Mark Morgan Lloyd Note Added: 0071562
2013-11-25 11:07 Mark Morgan Lloyd Note Added: 0071574
2013-11-25 13:33 Martin Friebe Note Added: 0071582
2013-11-25 14:11 Mark Morgan Lloyd Note Added: 0071584
2013-11-27 10:57 Mark Morgan Lloyd Note Added: 0071640
2013-11-27 14:15 Martin Friebe Note Added: 0071646
2013-11-27 15:51 Mark Morgan Lloyd Note Added: 0071648
2013-11-28 15:02 Mark Morgan Lloyd Note Added: 0071680
2013-11-28 15:11 Martin Friebe Note Added: 0071681
2013-11-28 15:13 Martin Friebe Note Edited: 0071681 View Revisions
2013-11-28 17:56 Mark Morgan Lloyd Note Added: 0071687
2013-11-29 09:10 Sven Barth Note Added: 0071694
2013-11-29 09:42 Mark Morgan Lloyd Note Added: 0071695
2013-11-29 14:28 Martin Friebe Note Added: 0071698
2013-11-29 16:44 Sven Barth Note Added: 0071703
2013-11-29 17:36 Mark Morgan Lloyd Note Added: 0071704
2013-11-29 18:17 Mark Morgan Lloyd File Added: synedit_tests.xml
2013-11-29 18:18 Mark Morgan Lloyd Note Added: 0071705
2013-11-29 20:41 Martin Friebe Note Added: 0071708
2013-11-29 22:38 Mark Morgan Lloyd File Added: synedit_tests_ppc.xml
2013-11-29 22:39 Mark Morgan Lloyd Note Added: 0071710
2013-11-29 23:32 Martin Friebe Note Added: 0071711
2013-12-02 10:17 Mark Morgan Lloyd Note Added: 0071724
2013-12-03 17:58 Martin Friebe Note Added: 0071749
2013-12-04 14:42 Mark Morgan Lloyd Note Added: 0071767
2013-12-15 19:30 Mark Morgan Lloyd File Added: foldtestdata.diff
2013-12-15 19:38 Mark Morgan Lloyd Note Added: 0071906
2013-12-16 02:15 Martin Friebe Note Added: 0071913
2013-12-16 10:19 Mark Morgan Lloyd Note Added: 0071917
2013-12-16 14:01 Martin Friebe Note Added: 0071921
2013-12-18 11:12 Mark Morgan Lloyd Note Added: 0071948
2013-12-18 12:00 Sven Barth Note Added: 0071950
2013-12-18 12:12 Mark Morgan Lloyd Note Added: 0071951
2013-12-18 19:32 Mark Morgan Lloyd Note Added: 0071959
2013-12-19 13:17 Mark Morgan Lloyd Note Added: 0071966
2013-12-19 14:13 Martin Friebe Note Added: 0071970
2013-12-19 14:57 Mark Morgan Lloyd Note Added: 0071972
2013-12-19 16:38 Martin Friebe Note Added: 0071974
2013-12-19 17:03 Mark Morgan Lloyd Note Added: 0071975
2013-12-21 11:50 Mark Morgan Lloyd Note Added: 0071996
2013-12-21 16:52 Maxim Ganetsky Fixed in Revision => 43551
2013-12-21 16:52 Maxim Ganetsky Note Added: 0072001
2013-12-21 16:52 Maxim Ganetsky Status new => resolved
2013-12-21 16:52 Maxim Ganetsky Fixed in Version => 1.4
2013-12-21 16:52 Maxim Ganetsky Resolution open => fixed
2013-12-21 16:52 Maxim Ganetsky Assigned To => Martin Friebe
2013-12-21 16:52 Maxim Ganetsky Note Edited: 0072001 View Revisions
2013-12-21 17:53 Mark Morgan Lloyd Note Added: 0072002
2013-12-21 17:53 Mark Morgan Lloyd Status resolved => closed