[fpc-devel]Recompile the RTL to trace bugs

Yakov Sudeikin yashka at exebook.com
Mon May 3 19:09:58 CEST 2004

Giulio and All,

if you really want to do that and fix the problem, I also will be very
happy, so maybe that will be an extra motivation for you :)

For two years I have been trying FPC on my projects, that use dynarrays
heavily. There were always problems, first year I was patiently reporting
each new problem, but when I saw that they never go away, or go away and
then return, or go away in few month to let me see next problem, I decided
that this way the dynarrays in FPC will only work after 10 years, so I gave
up. SetLength for dynarrays and openarrays, was always corrupting memory. It
was fixed many times, and still does that again. And yes, you cannot often
creat simple programs to bug report them. It probably has to do something
with functions calling, releasing memory at the end of function, or
something of that sort.

I guess the problem with dynarrays and openarrays (also as with overloaded
functions wich are also very buggy for a long time) is the fact that FPC
core team are old stylish programmers, and do not use these modern features
themselves. Thus these features are "for users" and are not so solid.
Instead you guys use pointers to arrays, getmem and other manually
controlled "dynamic arrays" and other structures, but not actual pascal
dynarrays. Same with openarrays and overloaded functions. I guess what you
could do, strictly IMHO, is start using these features across the compiler
code, so all your regression tests and other tests will constantly keep the
dynarray features healthy.

Thank you,
Yakov Sudeikin

----- Original Message -----
From: "Giulio Bernardi" <ugilio at hotmail.com>
To: <fpc-devel at lists.freepascal.org>
Sent: Monday, May 03, 2004 4:25 PM
Subject: [fpc-devel]Recompile the RTL to trace bugs

> Hi.
> I'm writing a sort of "compiler" for a language similar to php (so it is
> a compiler since
> it doesn't produce any object code, it only checks syntax and so on). I
> delphi 6 on
> win32, and freepascal 1.9.x on Linux/i386 and Mac OS X. Sometimes I
> it with
> fpc under win32 too.
> It works great when compiled with fpc 1.9.0, but I have strange problems
> when using
> fpc 1.9.2 and 1.9.3: it compiles correctly, but I have a lot of acces
> violations when running
> the program, and the program behaves differently when compiled with or
> without range checking.
> This program makes an heavy use of dynamic arrays and recursion.
> I tried to debug it using gdb, and I noticed a bad behavoir in setlength
> function:
> I have a method that adds things to a dynamic array, using setlength to
> increase its size dinamically.
> When the array is empty, everything is okay (array grows to 1, and data is
> set). When I add another
> item, array grows to 2, but contents of the first element (element 0) are
> corrupted: when I try to
> access it, sometimes i receive garbage data, sometimes I have an access
> violation.
> I have this same problem under win32, linux/i386 and MacOS X.
> I wasn't able to reproduce the bug in a simple program, so I would like to
> step into setlength to see
> what does happen.
> So, how can I compile a "debug version" of rtl so that I can use it when
> debugging the program?
> Thanx,
> Giulio
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel

More information about the fpc-devel mailing list