After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 652523 - Vala Gee LinkedList Problem : Memory allocation fails when list size > 1000000
Vala Gee LinkedList Problem : Memory allocation fails when list size > 1000000
Status: RESOLVED DUPLICATE of bug 652528
Product: vala
Classification: Core
Component: general
0.12.x
Other Mac OS
: Normal critical
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2011-06-14 06:50 UTC by Serge Hulne
Modified: 2011-06-14 09:17 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Serge Hulne 2011-06-14 06:50:43 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.
Comment 1 Maciej (Matthew) Piechotka 2011-06-14 09:17:55 UTC
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 ***