Sign in Join

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

Mailing lists / fpc-pascal / 2010-12

Need help fixing leaks

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

leledumbo

Could anyone please help me fixing leaks in my
http://free-pascal-general.1045716.n5.nabble.com/file/n3312878/llvmirbuilder.zip project ?
This is the output when I debug in gdb:

Program received signal SIGSEGV, Segmentation fault. 0x00000000 in ?? ()
(gdb) bt
#0 0x00000000 in ?? ()
#1 0x00406c32 in SYSTEM_TOBJECT_$__FREE ()
#2 0x0040d916 in TFPGOBJECTLIST$TLLVMVALUE__DEREF (ITEM=0x55138, this=<error reading variable>) at llvmirbuilder.pp:362 #3 0x00421451 in FGL_TFPSLIST_$__DEREF$LONGINT$LONGINT () #4 0x00000000 in ?? ()

That line is the end of a method and I have no idea why the item got dereferenced.

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Need-help-fixing-leaks-tp3312878p3312878.html Sent from the Free Pascal - General mailing list .

Reply by email

Jonas Maebe
to leledumbo
leledumbo wrote 17 lines
Could anyone please help me fixing leaks in my http://free-pascal-general.1045716.n5.nabble.com/file/n3312878/llvmirbuilder.zip project ? This is the output when I debug in gdb: Program received signal SIGSEGV, Segmentation fault. 0x00000000 in ?? () (gdb) bt #0 0x00000000 in ?? () #1 0x00406c32 in SYSTEM_TOBJECT_$__FREE () #2 0x0040d916 in TFPGOBJECTLIST$TLLVMVALUE__DEREF (ITEM=0x55138, this=<error reading variable>) at llvmirbuilder.pp:362 #3 0x00421451 in FGL_TFPSLIST_$__DEREF$LONGINT$LONGINT () #4 0x00000000 in ?? () That line is the end of a method and I have no idea why the item got dereferenced.

If you have access to a Linux or Mac OS X system, you can compile it with -gv and run it under Valgrind. It's very good at finding memory problems. Note that it may also give some false about the use of uninitialised values in some RTL helpers like fpc_pchar_to_shortstr (search for 80808080 in rtl/i386/* to see the routines where this can happen).

Jonas

Reply by email

Thomas Schatzl
to leledumbo: Could anyone please help me fixing leaks in my…

Hi,

leledumbo wrote 13 lines
[...] Program received signal SIGSEGV, Segmentation fault. 0x00000000 in ?? () (gdb) bt #0 0x00000000 in ?? () #1 0x00406c32 in SYSTEM_TOBJECT_$__FREE () #2 0x0040d916 in TFPGOBJECTLIST$TLLVMVALUE__DEREF (ITEM=0x55138, this=<error reading variable>) at llvmirbuilder.pp:362 #3 0x00421451 in FGL_TFPSLIST_$__DEREF$LONGINT$LONGINT () #4 0x00000000 in ?? () That line is the end of a method and I have no idea why the item got dereferenced.

At least one issue seems to be that all your TFPGObjectLists are owners of their respective instances. This leads to multiple attempted Free() calls to the objects in the list. If I am correct, there are/will be up to three Free() calls for some objects in your example code.

I may be wrong, I did not really debug the code, just from

Reply by email

leledumbo
to Thomas Schatzl
Show quoted text 6 lines
At least one issue seems to be that all your TFPGObjectLists are owners of their respective instances. This leads to multiple attempted Free() calls to the objects in the list. If I am correct, there are/will be up to three Free() calls for some objects in your example code. I may be wrong, I did not really debug the code, just from , I realize that too. So I'm refactoring the classes now. This is

quite difficult since I may generate a constant on the fly (encapsulated by a class) and in other time a reference to an instruction previously created. Who is responsible to free who is the problem.

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Need-help-fixing-leaks-tp3312878p3313416.html Sent from the Free Pascal - General mailing list .

Reply by email