Forum > General

Questions and Comments regarding Project Imported from Delphi


Hi all:

I'm working on porting the SLAMM Model (environmental open-source model) from Delphi to Lazarus.  I'm very new with Lazarus, though 15 years with Delphi.  Need to get the project to 64-bit ASAP so in the process of porting it.  (I would put this post in the Delphi "package" forum but this is not a package that I'm working with...)

Having some frustration with a few errors that I can't debug myself.  I'm a bit shy of using the Bugtracker due to my inexperience with Lazarus.  (i.e. There's a good chance the error is my own.)  Working with 0.9.29 with FPC 2.4.0...  (All the code runs stably on Delphi...)

First problem, a SIGSEGV when resizing a TSTRINGGRID.  The problem is initiated by my code which states: "With StringGrid1 do RowCount := NRows+1;"  (NRows is an integer set to 64).  This line then raises an error within DynamicArray.pas Line 134: (TArray.SetLength).  I'm leaning towards reporting this problem in Bugtracker as I can't see what I could have done wrong by just resizing the grid.  However, is there any protocol I should know about other than just searching to see if the "bug" has already been reported?

Second problem, SIGSEGV after reading from a TSTREAM object.  This software can read model parameters from a text file or a binary filestream.  After reading from the text file there is no problem.  After seemingly successfully reading the exact same data from the filestream and displaying the form, a SIGSEGV is thrown on SendPaintMessage (, line 386).  So this is a mystery to me...  I watched the data load from the Filestream and it is not corrupted.  Have I corrupted the memory somehow with my object handling?  (I do "free" the TFileStream after use.)  The error occurs after the button press procedure has completed and the form is being displayed again.  It's a mystery to me that reading data in one way causes this crash but the other way is always stable.  Is there any way that I can track down the cause of this error further before submitting it to Bugtracker?  (I can't imagine how anyone could track this down without my full source which isn't a problem but would be time consuming to distribute and get running on someone else's computer.)

I guess the second question is, therefore, any advice on tracking down a seemingly "random" though reproducible SIGSEGV?

Thanks so much and sorry about the long post.  JonC

I am not sure about your specific problems, but if you can make a minimal project to reproduce these problems and post them here or in the bug tracker, I am sure people will try to reproduce and fix your problems.
You should not be shy to post bugs. Make sure you specify your OS, Lazarus and FPC versions you have.

If the problems cannot be reproduced in a minimal program then it is much harder to point them out by the Lazarus/FPC developers if it is possible at all.

I put the code that was causing the crashes into a set of simple applications but could not reproduce the crash when it was stand-alone.  Quite frustrating.

So after a long day of debugging I realized that all of the errors were somehow caused by memory corruption when loading from either the TStream or the Text file.  Something in an object constructor was corrupting the memory and causing random crashes on screen displays and TStringGrid displays.  So I was in the compiler options setting up memory leak detection when I found the following option

Compiler Options, Parsing, Syntax Mode, "Delphi (-Mdelphi)"

Turning this on makes my software MUCH more stable (though not perfect yet, stray SIGSEGVs persist.)

I guess that I thought all of the {$MODE Delphi} compiler options within my code would have handled this.  Or that when I converted this project from Delphi that the "Delphi syntax mode" compiler option would have been automatically turned on...

Are there any documents describing the difference between these two syntax modes?  I'm just curious as to what in my code is Delphi syntax compatible but not Object Pascal syntax compatible?

Next, I try to move this nearly stable into 64 bit code and see if it explodes...

Thanks  -- JonC


--- Quote ---Are there any documents describing the difference between these two syntax modes?
--- End quote ---
Yes, please check here.


[0] Message Index

Go to full version