stxxl::queue - crash when out of scope.

Sukesh
2012-03-10
2013-04-25
  • Sukesh
    Sukesh
    2012-03-10

    Hi ,
    Appreciate for help -  I am trying to do very basic stxxl::queue test as follws but crash when queue goes out of scope ( partial copy code from test_queue.cpp ).

      typedef unsigned my_type;
       unsigned cnt;

        stxxl::queue<my_type> xqueue(2, 2, -1);
        std::queue<my_type> squeue;
        check(xqueue, squeue);

        STXXL_MSG("Testing special case 4");
        cnt = stxxl::queue<my_type>::block_type::size;
        while (cnt-)
        {
            my_type val = rnd();
            xqueue.push(val);
            squeue.push(val);
            check(xqueue, squeue);
        }
        cnt = stxxl::queue<my_type>::block_type::size;
        while (cnt-)
        {
            xqueue.pop();
            squeue.pop();
            check(xqueue, squeue);
        }

    when xqueue is out of scope either from a seperate function or main - it crash. How to use use stxxl::queue.
    Please help.

     
  • Sukesh
    Sukesh
    2012-03-12

    Hello ,
    can someone please help , it looks like if I pop all elements from stxxl::queue, when queue destructor is called  ( out of scope or explicit delete ) , it tries to delete the pool and crash. I just want to know if  stxxl::queue usage is correct or not.
    From test_queue.cpp  , if I do same operation  ]it also crash - is it a known issue that stxxl::queue never works ? Please help , I really need external memory queue implementation.   Thanks .

    Really looking for some help or answer or correct usage .

    Regards
    Sukesh

     
  • Please post the source code of a working program, not just some code fragment. (Working in the sense: this program can be compiled and exhibits the error when run).

    What platform are you working on? OS, Arch, Compiler, …
    What version of stxxl do you use? Did you try SVN trunk?

    Andreas

     
  • Sukesh
    Sukesh
    2012-03-13

    Hi ,
    Thank you very much for looking into it. Here is the details  with complete code - please help.

    1.  OS - WIndows 7,  VC10.
    2.  stxxl version 1.3.1 + Boost 1.47
    3. I don't know what is SVN trunk - what is it ?

    Please see code below -

    #include "stdafx.h"
    #include <iostream>
    #include <vector>

    #include <stdlib.h>
    #include <time.h>
    #include <string.h>
    #include <windows.h>

    #include <cstddef>
    #include <boost/cstdint.hpp>
    #include <queue>
    #include <stxxl/queue>
    #include <stxxl/vector>
    #include <boost/shared_ptr.hpp>

    typedef unsigned int my_type;

    void PushAndPopSingleQueue()
    {
    std::size_t const valueCount = 10; // * 1000 * 1000; // * 1000;

    STXXL_MSG("SEED=" << stxxl::get_next_seed());
        stxxl::srandom_number32(stxxl::get_next_seed());
        stxxl::random_number32_r rnd;

    stxxl::queue<my_type> xqueue( 3, 2, -1);

    {
    std::cout << "Start push-back" << std::endl;
    boost::uint64_t timeStart = ::GetTickCount();
    for (std::size_t i = 0; i < valueCount; ++i)
    {
    my_type val = rnd();
    xqueue.push(val);
    }
    std::cout << "Duration push-back: " <<
    ::GetTickCount() - timeStart << std::endl;
    }

    printf("size = %d", xqueue.size());

    {
    std::cout << "Start pop-front" << std::endl;
    boost::uint64_t timeStart = ::GetTickCount();
    for (size_t j = 0; j < valueCount; ++j)
    {
    my_type val = xqueue.front();
    xqueue.pop();
    }

    size_t xx;
    xx = xqueue.size();
    printf("size = %d", xqueue.size());
    std::cout << "Duration pop_front: " <<
    ::GetTickCount() - timeStart << std::endl;
    }
    }

    int _tmain(int argc, _TCHAR* argv)
    {
    PushAndPopSingleQueue();
    // Crash Here.
    return 0;
    }

    Code -