[gtkada] Memory allocation issue in GtkAda 3.8 - update

Rob Groen robgr at xs4all.nl
Sun Jul 6 15:00:37 CEST 2014


When testing with my sample 
<http://robgr.home.xs4all.nl/gtkada3x_bug.zip> on Ubuntu 14.04 no 
problems were found, in agreement with what was found by Emmanuel 
regarding his tests on OSX (thanks for trying).

In Win7 (both 64 and 32 bit versions) using GNAT GPL 2014 I played 
around bit with my test application, and found the following:
- stripping down the test program 
<http://robgr.home.xs4all.nl/gtkada3x_bug.zip> to only a GtkListStore is 
enough to reproduce the problem
- when commenting out in Gtk.Tree_Models.Get_String (body) the call to 
Interfaces.C.Strings.Free (A) (line 159) the problem disappears!
- when changing the body of Gtk.Tree_Models.Get_String with a 
Glib.Values.Get_String implementation the problem also disappears.

The GNAT version doesn't seem to matter, with the GNAT 2012 GPL version 
and Gtkada 3.8 my test program behaves the same.

My conclusion is that there is (still) interference with the memory 
allocation. Having found an apparent workaround, on Win7 I will use a 
patched version of GtkAda3.8.

I am interested though, if anyone using the same configuration (Win7, 
GNAT GPL) can reproduce my scenario. See the test sample 
<http://robgr.home.xs4all.nl/gtkada3x_bug.zip>

Regards, Rob

On 29-06-14 19:30, Dmitry A. Kazakov wrote:
> 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.
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/gtkada/attachments/20140706/8b5e9a1d/attachment.html>


More information about the gtkada mailing list