Segfault adding boxed enum to gee collection
I think I vaguely remember being told this is a known problem, but just ran into it and couldn't find it anywhere, so here's a test case.
The following works fine inserting an int, but segfaults on adding the an enum to a gee collection:
enum Test { ZERO, ONE; }
void main() {
// works fine
var int_list1 = new Gee.LinkedList<int?>();
int_list1.add((int?) 1);
// segfault on add
var enum_list1 = new Gee.LinkedList<Test?>();
enum_list1.add((Test?) Test.ONE);
}
Relevant generated C code looks like:
_tmp0_ = gee_linked_list_new (G_TYPE_INT, (GBoxedCopyFunc) _int_dup, (GDestroyNotify) g_free, NULL, NULL, NULL);
#line 6 "enum-collections.vala"
int_list1 = _tmp0_;
#line 7 "enum-collections.vala"
_tmp2_ = 1;
#line 7 "enum-collections.vala"
_tmp3_ = __int_dup0 (&_tmp2_);
#line 7 "enum-collections.vala"
_tmp1_ = _tmp3_;
#line 7 "enum-collections.vala"
gee_abstract_collection_add ((GeeAbstractCollection*) int_list1, _tmp1_);
#line 10 "enum-collections.vala"
_tmp4_ = gee_linked_list_new (TYPE_TEST, (GBoxedCopyFunc) _test_dup, (GDestroyNotify) g_free, NULL, NULL, NULL);
#line 10 "enum-collections.vala"
enum_list1 = _tmp4_;
#line 11 "enum-collections.vala"
gee_abstract_collection_add ((GeeAbstractCollection*) enum_list1, (gpointer) ((gintptr) ((Test*) TEST_ONE)));
Stack trace looks like:
Program received signal SIGSEGV, Segmentation fault.
0x000055555555537d in _test_dup (self=0x1) at enum-collections.vala:10
10 var enum_list1 = new Gee.LinkedList<Test?>();
(gdb) bt
#0 0x000055555555537d in _test_dup (self=0x1) at enum-collections.vala:10
#1 0x00007ffff7f270a5 in gee_linked_list_real_add
(base=0x5555555709b0 [GeeLinkedList], item=0x1) at linkedlist.c:1026
#2 0x0000555555555474 in _vala_main () at enum-collections.vala:11
#3 0x00005555555554f4 in main (argc=1, argv=0x7fffffffdd78) at enum-collections.vala:4