`pointer being freed was not allocated`

Lostsoul
2012-05-13
2013-04-25
  • Lostsoul
    Lostsoul
    2012-05-13

    My code seems to work(I haven't tried it with large datasets because of the above error).

    Code:

    #include <iostream>
    #include <queue>
    #include <stxxl/queue>

    int main()
    {
       //queue<int> q; //this works
       stxxl::queue<int> q; //does not work
       for (int i = 0; i<100; i++) {
           q.push(i);
       }
       std::cout << "done copying" << std::endl;
       while (q.empty() == false) {
           std::cout << q.front() << std::endl;
           q.pop();
       }
       std::cout << "done poping" << std::endl;
       return 0;
    }
    my simple .stxxl is simply: disk=./testfile,0,syscall

    But my error is:

    example (3884) malloc: *** error for object 0x101c04000: pointer being freed was not allocated
    *** set a breakpoint in malloc_error_break to debug
    The program has unexpectedly finished.
    I'm not sure how to troubleshoot it, do I need to free memory in this case? I'm still learning c++ so sorry if this is really basic(this only happens when I use the stxxl queue).

    Is there anything I'm doing wrong?

     
  • Lostsoul
    Lostsoul
    2012-05-13

    Also if it helps, I'm using Mac OS lion and stxxl 1.3.1  and gcc 4.2