[gtkada] Problem Report to file gtk-extra-plot_data.adb, function Get_Labels

h.michael.foerster h.michael.foerster at web.de
Sun Oct 27 12:59:00 CET 2002


This report is related to PR 8223, 8177, 8088, 6452, 5679 of the GCC 3.X 
bug list.

  2) Gtk-Ada Problem: allocating about 8GB of stack and Gigi unknown 
error using gcc3.2:
    a) The roblem is located in file gtk-extra-plot_data.adb, function 
Get_Labels.
      The code part is:
         function Get_Labels (Data : access Gtk_Plot_Data_Record)
            return Gtkada.Types.Chars_Ptr_Array
         is
            type Str_Array is array (Natural) of Chars_Ptr;
            type pStr_Array is access Str_Array ;
            function Internal (Data : System.Address) return Str_Array;
            pragma Import (C, Internal, "gtk_plot_data_get_labels");
     
            N : constant size_t := size_t (Get_Numpoints (Data));
         begin
            return Chars_Ptr_Array
              (Internal (Get_Object (Data))(0 .. Integer (N) - 1));
         end Get_Labels;

      The code for gtk_plot_data_get_labels is in file gtkplotdata.c:
        gchar **
        gtk_plot_data_get_labels(GtkPlotData *dataset, gboolean 
*show_labels)
        {
          *show_labels = dataset->show_labels;
          return(dataset->labels);
        }

     In my opinion, the code part is never used in Gtk-Ada otherwise a 
program will crash, because:
     i) gtk_plot_data_get_labels returns a pointer _NOT_ an array
     ii) gtk_plot_data_get_labels needs a second parameter on the stack, 
a reference to a variable: show_labels,
       and this varaible will be filled with an address.

    b) Fixing:
      Change the code part of file gtk-extra-plot_data.adb as follow and 
it will compile...:
         function Get_Labels (Data : access Gtk_Plot_Data_Record)
            return Gtkada.Types.Chars_Ptr_Array
         is
            type Str_Array is array (Natural) of Chars_Ptr;
            type pStr_Array is access Str_Array ; -- new
--            function Internal (Data : System.Address) return Str_Array;
            function Internal (Data : System.Address) return pStr_Array; 
-- new
            pragma Import (C, Internal, "gtk_plot_data_get_labels");
     
            N : constant size_t := size_t (Get_Numpoints (Data));
         begin
            return Chars_Ptr_Array
--              (Internal (Get_Object (Data))(0 .. Integer (N) - 1));
              (Internal (Get_Object (Data)).all(0 .. Integer (N) - 1)); 
-- new
         end Get_Labels;

Please inform me if my my point of view is correct.

With best regards
Michael Foerster

-- 
==============================
Michael Fo"rster
Grillstr.6
D84453 Mu"hldorf

e-mail: h.michael.foerster at web.de

tel: +49 8631 140158
==============================






More information about the gtkada mailing list