[gtkada] memory allocation problems in Gtkada 3.4.2?

Ludovic Brenta ludovic at ludovic-brenta.org
Mon Mar 24 22:00:08 CET 2014


Rob Groen writes:
> The problem is getting worse. Another application that I migrated to
> GtkAda 3.4.2 has the same problems. And that applications does nothing
> "naughty" with Gtkada or Glib. I was able to nail the spot where the
> application crashes. The code is used for reading a text file and
> analyzing its contents and presenting the result in a treeview. After
> reading 46 lines from the input file the application crashes. In that
> piece of code I use allocators. and since the debugger trace showed
> malloc related code I removed the allocators and changed is to
> something that doesn't. Now lo and behold, the applications runs
> fine. Then, for arguments sake in the loop that reads the file I just
> added one line with Tmp := new String'(""); The applications crashes
> again after reading 46 lines. Remove the string allocator, all works
> OK.  I also tried going back to a previous version of the
> compiler. Same results: Gtkada 2.24.2 Ok for both compiler versions,
> Gtkada 3.4.2 not OK.  I am kind of stuck now. Does anybody experiences
> the same kind of issues?

A stab in the dark: these problems make it sound like there are two
competing memory allocators: one in GTK+ and the other in the Ada
runtime.  They seem to step on each other's toes.  In theory, both
allocators should ultimately be malloc from glibc but there is always a
chance that either GTK+ or the Ada RTS tries to do something "clever"
like perhaps using tcmalloc.  Or, maybe one uses 64-bit alignment while
the other uses 32-bit alignment.

If I were you I would investigate in this direction.

-- 
Ludovic Brenta.


More information about the gtkada mailing list