Backport upstream fix for lablgtk segfaults in unison:

Upstream commit 60a61fabb5d9836e69130bf7c07eea206fe20928

2014.09.20 [Jacques]
  * CAMLparam initializes with Val_unit rather than 0 since ocaml 4.02.
    Fix a related problem in ml_gobject (Christopher Zimmermann, PR#1425)
  * Also factorize some code to use Val_option_*


ok avsm@
This commit is contained in:
chrisz 2014-09-22 11:37:42 +00:00
parent 9953b7621e
commit 642de2ced4
9 changed files with 250 additions and 9 deletions

View File

@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.33 2014/09/19 12:52:02 chrisz Exp $
# $OpenBSD: Makefile,v 1.34 2014/09/22 11:37:42 chrisz Exp $
COMMENT = OCaml interface to GTK+2
V = 2.18.2
REVISION = 0
REVISION = 1
DISTNAME = lablgtk-$V
PKGNAME = lablgtk2-$V
CATEGORIES = x11 devel

View File

@ -0,0 +1,17 @@
$OpenBSD: patch-CHANGES,v 1.1 2014/09/22 11:37:42 chrisz Exp $
Upstream commit 60a61fabb5d9836e69130bf7c07eea206fe20928
--- CHANGES.orig Thu Sep 18 08:47:06 2014
+++ CHANGES Sat Sep 20 10:58:31 2014
@@ -1,5 +1,10 @@
LablGTK changes log
+2014.09.20 [Jacques]
+ * CAMLparam initializes with Val_unit rather than 0 since ocaml 4.02.
+ Fix a related problem in ml_gobject (Christopher Zimmermann, PR#1425)
+ * Also factorize some code to use Val_option_*
+
In Lablgtk-2.18.2:
2014.09.17 [Jacques]

View File

@ -1,16 +1,36 @@
$OpenBSD: patch-src_ml_gobject_c,v 1.1 2014/09/19 12:52:02 chrisz Exp $
$OpenBSD: patch-src_ml_gobject_c,v 1.2 2014/09/22 11:37:42 chrisz Exp $
Fix segfault in unison. Val_unit is an unboxed integer, which is not zero.
Use the apropriate macro for checking whether ret has been initialized.
Upstream commit 60a61fabb5d9836e69130bf7c07eea206fe20928
--- src/ml_gobject.c.orig Fri Sep 19 14:36:30 2014
+++ src/ml_gobject.c Fri Sep 19 14:40:49 2014
@@ -671,7 +671,7 @@ CAMLprim value ml_g_signal_emit_by_name (value obj, va
2014.09.20 [Jacques]
* CAMLparam initializes with Val_unit rather than 0 since ocaml 4.02.
Fix a related problem in ml_gobject (Christopher Zimmermann, PR#1425)
* Also factorize some code to use Val_option_*
--- src/ml_gobject.c.orig Thu Sep 18 08:47:06 2014
+++ src/ml_gobject.c Sat Sep 20 10:58:31 2014
@@ -643,8 +643,8 @@ ML_2 (g_signal_handler_is_connected, GObject_val, Long
ML_2 (g_signal_stop_emission_by_name, GObject_val, String_val, Unit)
CAMLprim value ml_g_signal_emit_by_name (value obj, value sig, value params)
{
- CAMLparam3(obj,sig,params);
- CAMLlocal1(ret);
+ value ret = Val_unit;
+ CAMLparam4(obj,sig,params,ret);
GObject *instance = GObject_val(obj);
GValue *iparams = (GValue*)calloc(1 + Wosize_val(params), sizeof(GValue));
GQuark detail = 0;
@@ -671,11 +671,11 @@ CAMLprim value ml_g_signal_emit_by_name (value obj, va
query.param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE);
g_value_set_mlvariant (&iparams[i+1], Field(params,i));
}
- g_signal_emitv (iparams, signal_id, detail, (ret ? GValue_val(ret) : 0));
+ g_signal_emitv (iparams, signal_id, detail, (Is_block(ret) ? GValue_val(ret) : 0));
+ g_signal_emitv (iparams, signal_id, detail,
+ (ret == Val_unit ? 0 : GValue_val(ret)));
for (i = 0; i < query.n_params + 1; i++)
g_value_unset (iparams + i);
free (iparams);
- if (!ret) ret = Val_unit;
CAMLreturn(ret);
}

View File

@ -0,0 +1,32 @@
$OpenBSD: patch-src_ml_gtk_c,v 1.1 2014/09/22 11:37:42 chrisz Exp $
Upstream commit 60a61fabb5d9836e69130bf7c07eea206fe20928
2014.09.20 [Jacques]
* CAMLparam initializes with Val_unit rather than 0 since ocaml 4.02.
Fix a related problem in ml_gobject (Christopher Zimmermann, PR#1425)
* Also factorize some code to use Val_option_*
--- src/ml_gtk.c.orig Thu Sep 18 08:47:06 2014
+++ src/ml_gtk.c Sat Sep 20 10:58:31 2014
@@ -402,7 +402,7 @@ CAMLprim value ml_gtk_widget_style_get_property (value
pspec = gtk_widget_class_find_style_property
(GTK_WIDGET_GET_CLASS (widget), name);
if (pspec) {
- value ret = ml_g_value_new ();
+ ret = ml_g_value_new ();
GValue *gv = GValueptr_val (ret);
g_value_init (gv, G_PARAM_SPEC_VALUE_TYPE (pspec));
gtk_widget_style_get_property (widget, name, gv);
@@ -737,8 +737,9 @@ CAMLprim value ml_gtk_file_selection_get_selections (v
gchar** selections =
gtk_file_selection_get_selections(GtkFileSelection_val(sel));
gchar** orig = selections;
- CAMLparam0();
- CAMLlocal3(ret,prev,next);
+ value ret = Val_unit;
+ CAMLparam1(ret);
+ CAMLlocal2(prev,next);
for (prev = (value)((&ret)-1); *selections != NULL; selections++) {
next = alloc(2,0);
Store_field(prev, 1, next);

View File

@ -0,0 +1,20 @@
$OpenBSD: patch-src_ml_gtkfile_c,v 1.1 2014/09/22 11:37:42 chrisz Exp $
Upstream commit 60a61fabb5d9836e69130bf7c07eea206fe20928
2014.09.20 [Jacques]
* CAMLparam initializes with Val_unit rather than 0 since ocaml 4.02.
Fix a related problem in ml_gobject (Christopher Zimmermann, PR#1425)
* Also factorize some code to use Val_option_*
--- src/ml_gtkfile.c.orig Thu Sep 18 08:47:06 2014
+++ src/ml_gtkfile.c Sat Sep 20 10:58:31 2014
@@ -99,7 +99,7 @@ static gboolean ml_gtk_file_filter_func (const GtkFile
{
value *cb = data;
CAMLparam0();
- CAMLlocal5(r, l, v, t, s);
+ CAMLlocal4(r, l, v, s);
l = Val_emptylist;
#define CONS_MEMBER(memb, flag) \
if (filter_info->contains & GTK_FILE_FILTER_##flag) { \

View File

@ -0,0 +1,30 @@
$OpenBSD: patch-src_ml_gtkmenu_c,v 1.1 2014/09/22 11:37:42 chrisz Exp $
Upstream commit 60a61fabb5d9836e69130bf7c07eea206fe20928
2014.09.20 [Jacques]
* CAMLparam initializes with Val_unit rather than 0 since ocaml 4.02.
Fix a related problem in ml_gobject (Christopher Zimmermann, PR#1425)
* Also factorize some code to use Val_option_*
--- src/ml_gtkmenu.c.orig Thu Sep 18 08:47:06 2014
+++ src/ml_gtkmenu.c Sat Sep 20 10:58:31 2014
@@ -62,16 +62,8 @@ ML_0 (gtk_tearoff_menu_item_new, Val_GtkWidget_sink)
ML_1 (gtk_menu_item_new_with_label, String_val, Val_GtkWidget_sink)
ML_1 (gtk_menu_item_new_with_mnemonic, String_val, Val_GtkWidget_sink)
ML_2 (gtk_menu_item_set_submenu, GtkMenuItem_val, GtkWidget_val, Unit)
-
-CAMLprim value ml_gtk_menu_item_get_submenu(value sm)
-{
- CAMLparam1(sm);
- CAMLlocal1(res);
- res = Val_option(gtk_menu_item_get_submenu(GtkMenuItem_val(sm)),
- Val_GtkWidget);
- CAMLreturn(res);
-}
-
+Make_Val_option(GtkWidget)
+ML_1 (gtk_menu_item_get_submenu, GtkMenuItem_val, Val_option_GtkWidget)
ML_1 (gtk_menu_item_remove_submenu, GtkMenuItem_val, Unit)
ML_2 (gtk_menu_item_set_accel_path, GtkMenuItem_val, String_val, Unit)
ML_1 (gtk_menu_item_activate, GtkMenuItem_val, Unit)

View File

@ -0,0 +1,80 @@
$OpenBSD: patch-src_ml_gtktext_c,v 1.1 2014/09/22 11:37:42 chrisz Exp $
Upstream commit 60a61fabb5d9836e69130bf7c07eea206fe20928
2014.09.20 [Jacques]
* CAMLparam initializes with Val_unit rather than 0 since ocaml 4.02.
Fix a related problem in ml_gobject (Christopher Zimmermann, PR#1425)
* Also factorize some code to use Val_option_*
--- src/ml_gtktext.c.orig Thu Sep 18 08:47:06 2014
+++ src/ml_gtktext.c Sat Sep 20 10:58:31 2014
@@ -121,25 +121,9 @@ CAMLprim value ml_gtk_text_iter_assign (value it1, val
ML_2(gtk_text_mark_set_visible, GtkTextMark_val, Bool_val, Unit)
ML_1(gtk_text_mark_get_visible, GtkTextMark_val, Val_bool)
ML_1(gtk_text_mark_get_deleted, GtkTextMark_val, Val_bool)
-CAMLprim value ml_gtk_text_mark_get_name (value tm)
-{
- CAMLparam1(tm);
- CAMLlocal1(res);
- const gchar* tmp;
- tmp = gtk_text_mark_get_name(GtkTextMark_val(tm));
- res = Val_option(tmp,Val_string);
- CAMLreturn(res);
-}
-CAMLprim value ml_gtk_text_mark_get_buffer (value tm)
-{
- CAMLparam1(tm);
- CAMLlocal1(res);
- GtkTextBuffer* tmp;
- tmp = gtk_text_mark_get_buffer(GtkTextMark_val(tm));
- res = Val_option(tmp,Val_GtkTextBuffer);
- CAMLreturn(res);
-}
-
+ML_1(gtk_text_mark_get_name, GtkTextMark_val, Val_option_string)
+Make_Val_option(GtkTextBuffer)
+ML_1(gtk_text_mark_get_buffer, GtkTextMark_val, Val_option_GtkTextBuffer)
ML_1(gtk_text_mark_get_left_gravity, GtkTextMark_val, Val_bool)
/* gtktexttag */
@@ -157,17 +141,9 @@ ML_1(Wrap_mode_val, (value), Val_int)
ML_0(gtk_text_tag_table_new, Val_GtkTextTagTable_new)
ML_2(gtk_text_tag_table_add, GtkTextTagTable_val, GtkTextTag_val,Unit)
ML_2(gtk_text_tag_table_remove, GtkTextTagTable_val, GtkTextTag_val,Unit)
-
-CAMLprim value ml_gtk_text_tag_table_lookup (value tv, value s)
-{
- CAMLparam2(tv,s);
- CAMLlocal1(res);
- GtkTextTag* tmp;
- tmp = gtk_text_tag_table_lookup(GtkTextTagTable_val(tv), String_val(s));
- res = Val_option(tmp,Val_GtkTextTag);
- CAMLreturn(res);
-}
-
+Make_Val_option(GtkTextTag)
+ML_2(gtk_text_tag_table_lookup, GtkTextTagTable_val, String_val,
+ Val_option_GtkTextTag)
ML_1(gtk_text_tag_table_get_size, GtkTextTagTable_val, Val_int)
static void tag_foreach_func (GtkTextTag* t, gpointer user_data)
@@ -625,15 +601,9 @@ CAMLprim value ml_gtk_text_view_window_to_buffer_coord
CAMLreturn(res);
}
-CAMLprim value ml_gtk_text_view_get_window (value tv, value tt)
-{
- CAMLparam2(tv,tt);
- CAMLlocal1(res);
- GdkWindow* tmp;
- tmp = gtk_text_view_get_window(GtkTextView_val(tv), Text_window_type_val(tt));
- res = Val_option(tmp,Val_GdkWindow);
- CAMLreturn(res);
-}
+Make_Val_option(GdkWindow)
+ML_2(gtk_text_view_get_window, GtkTextView_val, Text_window_type_val,
+ Val_option_GdkWindow)
ML_2(gtk_text_view_get_window_type,GtkTextView_val,GdkWindow_val,
Val_text_window_type)

View File

@ -0,0 +1,31 @@
$OpenBSD: patch-src_wrappers_c,v 1.1 2014/09/22 11:37:42 chrisz Exp $
Upstream commit 60a61fabb5d9836e69130bf7c07eea206fe20928
2014.09.20 [Jacques]
* CAMLparam initializes with Val_unit rather than 0 since ocaml 4.02.
Fix a related problem in ml_gobject (Christopher Zimmermann, PR#1425)
* Also factorize some code to use Val_option_*
--- src/wrappers.c.orig Thu Sep 18 08:47:06 2014
+++ src/wrappers.c Sat Sep 20 10:58:31 2014
@@ -61,8 +61,7 @@ CAMLprim value ml_some (value v)
value ml_cons (value v, value l)
{
CAMLparam2(v, l);
- CAMLlocal1(cell);
- cell = alloc_small(2, Tag_cons);
+ value cell = alloc_small(2, Tag_cons);
Field(cell, 0) = v;
Field(cell, 1) = l;
CAMLreturn(cell);
@@ -94,6 +93,9 @@ value copy_string_or_null (const char*str)
{
return copy_string (str ? (char*) str : "");
}
+
+value Val_option_string (const char *s)
+{ return Val_option (s, Val_string); }
CAMLprim value *ml_global_root_new (value v)
{

View File

@ -0,0 +1,11 @@
$OpenBSD: patch-src_wrappers_h,v 1.1 2014/09/22 11:37:42 chrisz Exp $
--- src/wrappers.h.orig Thu Sep 18 08:47:06 2014
+++ src/wrappers.h Sat Sep 20 10:58:31 2014
@@ -43,6 +43,7 @@ CAMLexport void ml_raise_null_pointer (void) Noreturn;
CAMLexport value Val_pointer (void *);
CAMLprim value copy_string_check (const char*);
value copy_string_or_null (const char *);
+value Val_option_string (const char *s);
value string_list_of_strv (const char * const *v);
value string_list_of_strv2 (char **v);