Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

C++ program debugged well with Cygwin4 (under Netbeans 7.2) but not with MinGW (under QT 4.8.1)



  • I have a c++ program that takes a map text file and outputs it to a graph data structure I have made. I am using QT as I needed cross-platform program and GUI as well as visual representation of the map. I have several maps in different sizes (8x8 to 4096x4096). I am using unordered_map with a vector as key and vertex as value, I'm sending hash(1) and equal functions which I wrote to the unordered_map in creation.

    Under QT I am debugging my program with QT 4.8.1 for desktop MinGW (QT SDK), the program works and debugs well until I try the largest map of 4096x4096, then the program gets stuck with the following error: "the inferior stopped because it received a signal from operating system". When debugging, the program halts at the hash function which used inside the unordered_map and not as part of the insertion state, but at a getter(2).

    Under Netbeans IDE 7.2 and Cygwin4 all works fine (debug and run).

    Some code info:
    @typedef std::vector<double> coordinate;
    typedef std::unordered_map<coordinate const*, Vertex<Element>*, container_hash, container_equal> vertexsContainer;
    vertexsContainer *m_vertexes
    @

    (1) hash function:
    @struct container_hash
    {
    size_t operator()(coordinate const *cord) const
    {
    size_t sum = 0;
    std::ostringstream ss;

        for ( auto it = cord->begin() ; it != cord->end() ; ++it )
        {
           ss << *it;
        }
    
        sum = std::hash<std::string>()(ss.str());
        return sum;
    }
    

    };@

    (2) the getter:
    @template <class Element>
    Vertex<Element> *Graph<Element>::getVertex(const coordinate &cord)
    {
    try
    {
    Vertex<Element> *v = m_vertexes->at(&cord);
    return v;
    }
    catch (std::exception& e)
    {
    return NULL;
    }
    }@

    • I was thinking maybe it was some memory issue at the beginning, so before I was thinking of trying Netbeans I checked it with QT on my friend pc with a 16GB RAM and got the same error.

    Update: I try to run this on visual studio 2012, I got a bad_alloc error which halt my program, when looking at task manager I saw the memory assigned to the program was going up to 2GB, could be it's because it's a 32bit program?

    Update: I debugged my program under Netbeans with 32bit architecture and Cygwin4 and all worked fine, so maybe it is not a 32 bit problem, also the memory used with netbeans was 1.5GB, so how in MinGW and VS2012 it's going up to 2GB?

    Thanks.


Log in to reply