GNOME Bugzilla – Bug 652523
Vala Gee LinkedList Problem : Memory allocation fails when list size > 1000000
Last modified: 2011-06-14 09:17:55 UTC
Example: NB : The example hereunder works perfectly with a number of elements <= 100,000 but crashes if one when the number of elements to insert in the List is >= 1000,000 . Serge. //----------- using Gee; using Posix; // Struct to hold key, values pairs struct pair { public uint freq; public string word; } // Comparison function for stucts int comp(pair a, pair b) { if( a.freq > b.freq) return -1; else if( a.freq < b.freq) return +1; else return 0; } // Equality function for structs bool equals (pair a, pair b) { if (Posix.strcmp(a.word, b.word) ==0 ) return true; else return false; } int main(string[] args) { //List var L = new LinkedList<pair?>( (EqualFunc) equals); // Insert in List (to sort) pair p = pair(); for (var i=0; i<1000000; i++) { p.word = "test"; p.freq = 1; L.add(p); } // Sort list L.sort( (CompareFunc)comp ); // Freq distribution var i = 0; foreach (var item in L) { Posix.printf("(%u,\t '%s')\n", item.freq, item.word); i++; if (i > 10) break; } return 0; } //----------- On Tue, Jun 14, 2011 at 12:52 AM, Serge Hulne <serge hulne gmail com> wrote: > the result of the run with gdb is: > > Program received signal EXC_BAD_ACCESS, Could not access memory. > Reason: KERN_PROTECTION_FAILURE at address: 0x00007fff5f3ffff8 > 0x00000001001500c4 in gee_linked_list_node_free (self=0x103ff67a0) at > linkedlist.c:1182 > 1182 static void gee_linked_list_node_free (GeeLinkedListNode* self) { > (gdb) > > Which seems to point to a memory access problem related to the Gee > GeeLinkedList container. > > > Apparently the GeeLinkedList tries to free (a) node(s) which has (have) > not been allocated.
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find. *** This bug has been marked as a duplicate of bug 652528 ***