[gtkada] Memory allocation issue in GtkAda 3.8 ?

Dmitry A. Kazakov mailbox at dmitry-kazakov.de
Sun Jun 29 19:30:56 CEST 2014


On Sun, 29 Jun 2014 18:11:33 +0200, you wrote:

> As a follow up on the discussion last March wrt memory allocation
> problems in GtkAda 3.x, I tried one of my failing programs with Gtkada
> 3.8. Unfortunately with the same result. 
> 
> I tried this on Windows 7, both on a 64- and on a 32-bit environment,
> using the GNAT GPL 2014 compiler. In order to track the problem I
> stripped my original application to a simple window with a treeview /
> liststore, consisting of one column of type Gtype_String. The liststore
> gets loaded with a nr of strings, then a search in the store is
> performed. In the search a Get_String is done on an element of the
> store. 
> 
> When an allocator is used prior searching ( sp := new String'("") ), the
> program crashes after a few searches. When either the allocator or the
> Get_String is omitted the program runs to completion.
> (The nr of strings to put into the store and the nr of searches vary
> with the code, logging statements, etc etc. The current nrs are those
> that crashes the program in my environments, Win7 32- and 64-bit.) 
> 
> For those who want to research / replay this issue a zip file with the
> code and a .gpr file can be found at:
> http://robgr.home.xs4all.nl/gtkada3x_bug.zip. The "offending" code is in
> the file gtkada3x_bug_support.adb.
> Unfortunately I do not have the knowledge to research this problem. 

If I correctly remember, I might be wrong, the problem is with the Set
procedure of Gtk_List_Store with a string argument.

A workaround is to use Set_Value instead. You do Init of a GValue with
GType_String. Set the string into it. Then Set_Value to update the list
store and, finally, Unset the GValue object.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


More information about the gtkada mailing list