[fpc-pascal] Problem with objects
el.es.cr at gmail.com
Wed Dec 23 16:24:45 CET 2015
On 23/12/15 09:37, Santiago Amposta wrote:
> I use fpc 2.6.4 and I have a problem of memory leaks, strange errors,
> etc. Finally I have tracked it to this:
> List:array of String;
> procedure TestSimple;
> procedure TestDerived;
> TestSimple; // Works Fine,
> TestDerived; // rises an exception SIGSEGV on setLength
> What am I doing wrong?
I might be wrong... but I just tried:
stepping into TestSimple in the order OP specified,
hovering over A.List (actually over .List only, see below*)
A.List = (0x0)
A.List = ()
after the setLength;
then stepped through to TestDerived, in which the hover over .List gives
A.List = ()
and an External: SIGSEGV At Address 403CDC when trying to step over setLength
Then if I change the order
TestDerived; // first
TestSimple; // second
and step through, the A.List in Test Derived is A.List = () from the start, it is as-if it was preinitialized?
But then. If I comment out the other_field, both routines pass through with A.List = (0x0) in TestSimple before SetLength,
it also seems to pass without a problem and without the * problem below, even with A.List = () before and after SetLength.
* problem : with the other_field still IN TDerivedArrayString,
if I step through the (passing with no error) TestSimple, and hover mouse over A, I get a GDB crash.
Regardless which A I hover over (the one in Test Derived does that too, even if out of scope
[execution point currently in the other Test procedure]
Again this does NOT happen with the other_field commented out.
If I run either one Test* procedures at a time between rebuilds, with other_field defined,
TestSimple passes with no error,
TestDerived shows .List hovering A.List = (0x10000 '=') ; hovering over A crashes GDB too;
Say if I only leave TestDerived call, and if I pause execution before SetLength,
hovering over .List in EITHER procedure shows A.List = () (yes even in TestSimple which is commented out in main begin..end;)
(and I get GDB crash when hovering over A of either procedure)
If I truly comment out the unused procedure, only leaving the one currently being tested, like TestDerived,
hovering over .List before SetLength call gives A.List = (0x10000 '=')
hovering over A crashes GDB
after rebuild, program completes with NO SIGSEGV.
FPC 2.6.4 under Lazarus 1.4.4 from tarball release [ 2015-10-03, svn 49931 i386-win32-win32/win64 ] under WinXP SP3.
More information about the fpc-pascal