Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Windows 7, MinGW, GNAT, mysterious problem

52 views
Skip to first unread message

Dmitry A. Kazakov

unread,
May 17, 2012, 3:50:40 AM5/17/12
to
There seems to be some very weird problem which I cannot identify. Maybe
somebody familiar with MinGW and GNAT/GCC innards can shed some light.

It started as a GtkAda problem, but now I am not sure if it really is. So I
reduced the sample code which originally was Ada to bare C in order to
exclude any Ada/C calling issues.

The code:
------------------------- test.c -------------------------
#include <stdio.h>
#include <gtk/gtk.h>

const gchar *test = "Test";
GtkVBox *vbox;
GtkWindow *win;

gboolean Timer (gpointer user_data)
{
gtk_widget_queue_draw (GTK_WIDGET (vbox));
return 1;
}

int main(int argc, char **argv)
{
gtk_init(&argc, &argv);
win = (GtkWindow*)gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(win, test);
vbox = (GtkVBox*)gtk_vbox_new(TRUE, 1);
gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(vbox));
g_timeout_add (200, Timer, 0);
gtk_widget_show_all(GTK_WIDGET(win));
gtk_main();
return 0;
}
--------------------------------------------------------------------
The project file:
------------- test.gpr ------------------------------------------
with "gtkada.gpr";
project Test is
for Languages use ("C");
for Main use ("test.c");
for Source_Files use ("test.c");
for Exec_Dir use ".";

package Compiler is
for Default_Switches ("c") use
("-mms-bitfields",
"-I../../lib/gtk-2.0/include",
"-I../../lib/gdk-2.0/include",
"-I../../lib/glib-2.0/include",
"-I../../include",
"-I../../include/atk-1.0",
"-I../../include/gdk-pixbuf-2.0",
"-I../../include/cairo",
"-I../../include/pango-1.0",
"-I../../include/gio-win32-2.0",
"-I../../include/glib-2.0",
"-I../../include/gtk-2.0",
"-g");
end Compiler;

package Linker is
for Default_Switches ("c") use
Gtkada.Linker'Default_Switches ("c") & "-g" & "-mwindows";
end Linker;
end Test;
--------------------------------------------------------------------
The program opens a window with a single box inside it and periodically
(200ms) calls gtk_widget_queue_draw on that box. The GTK implementation of
queue draw is, as far I can understand their code, basically invalidating
the window region for later refresh. It was tested with the newest Windows
GTK version 2.24.10, various GNAT compilers (up to GNAT PRO 7.0.1), no
difference.

Now the problem.

1. When compiled under Windows 7 64-bit, statically or dynamically linked,
the resulted program leaks. Slowly but steadily as the task manager shows.

2. When compiled under Windows XP 32- or 64-bit it does not leak.

3. An executable built on Windows XP and linked statically does not leak
when run under Windows 7. Dynamically linked executable leaks.

4. The most puzzling part is that when compiled under Windows XP 32 running
on a Windows 7 VirtualBox it leaks!

(I didn't checked all possible combinations because I have no access to all
platforms)

Any ideas?

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