Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-02

Guess the problem with Heap

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Aradeonas

Hi,

Im working on one of my projects and tried to make a release version, so I used shortcut button in build modes and add release mode but when I compile and run I get SIGSEGV error when main form want to be create. After many tries I found out that if I check "Use Heaptrc unit" in project debugging option program will run correctly even it is release mode so there is no debug info. So simple : If I check that option and use Heaptrc, no problem and if I unchecked it, error .

Its a old project and I dont remind any code I write about heap so I cant find the problem so I want to ask anyone can guess what code can make such problem?

Regards, Ara

http://www.fastmail.com - Accessible with your email software or over the web -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20160212/1c0447b6/attachment.html>

Reply by email

Martin Frb
to Aradeonas
Aradeonas wrote 14 lines
Hi, Im working on one of my projects and tried to make a release version, so I used shortcut button in build modes and add release mode but when I compile and run I get SIGSEGV error when main form want to be create. After many tries I found out that if I check "Use Heaptrc unit" in project debugging option program will run correctly even it is release mode so there is no debug info. So simple : If I check that option and use Heaptrc, no problem and if I unchecked it, error . Its a old project and I dont remind any code I write about heap so I cant find the problem so I want to ask anyone can guess what code can make such problem?
Common candidates are any code that
1) accesses memory behind or before allocatien
   dynArray[-10]  := x
   dynArray[length(dynArray)+10] := x
   foo := TObject.create;
   TChildClass(foo).something ....
   getmem, and then access outside the bounds
   pointer ....

2) any code accessing memory that was freed (any of the above)

-------
and worst of all, the error may or may not be triggered at the time of accessing the invalid mem. Sometimes it fails at some other completely valid code.

heaptrc changes memory layout as it stores the leaktrace info, and that means that by pure luck, the invalid memory access you do, does not affect the rest of your data. (or not anything that you detected yet)

A)
compile with heaptrc
and -Criot and any other flag you can find. Note the LCL does not work with -CR (upper R)

set the HEAPTRC environment to "keepreleased"

B)
If you can compile an Linux and run with valgrind.

Reply by email