#My sfml window crashes with code -1073741571

16 messages · Page 1 of 1 (latest)

dusty pumiceBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

quasi wren
#

use your debugger to find out what crashes where exactly

icy meadow
#

ok 1 minute

#
delete qt;
        qt = new Quadtree<Particle>(r, 4);

        for (const Particle& element : points) {
            qt->insert(element);
        }

it seems to be caused here in the insert function

#
void insert(T p) {
        if (this->points.size() < this->capacity)
            this->points.push_back(p);
        else {
            if (!divided)
                this->subdivide();

            if (ne->boundary.contains(p))
                ne->insert(p);
            else if (nw->boundary.contains(p))
                nw->insert(p);
            else if (se->boundary.contains(p))
                se->insert(p);
            else
                sw->insert(p);
        }
    }

which looks like this

#

saying Unhandled exception at 0x00007FF7F3A0D867 in LearningCpp.exe: 0xC00000FD: Stack overflow (parameters: 0x0000000000000001, 0x00000019A4A03000).

#

so from what ive read it seems ive caused a stack overflow which is suprising

#
vector<Particle> points(qt->getPoints());

        for (Particle& element : points) {
            element.cohesion(*qt, 100, 5);
            element.seperation(*qt, 20, 3);
            element.alignment(*qt, 100, 5);
            element.update(r.w, r.h);
            /*element.gravity(10, clock.getElapsedTime().asSeconds(), r.h);
            element.gravityUpdate(r.h);*/
        }

        std::cout << "5" << std::endl;

        delete qt;
        qt = new Quadtree<Particle>(r, 4);

        for (const Particle& element : points) {
            qt->insert(element);
        }

        std::cout << "6" << std::endl;

this is all my main function

dusty pumiceBOT
#

@icy meadow

Please Do Not Delete Posts!

Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.

quasi wren
#

you understand what a stack overflow is?

icy meadow
#

i know

#

i did close this

#

because im investigating this on my own rn the stack overflow is a subsequent problem from another problem ive found

quasi wren
#

it seems like your recursive insert() function just doesn't terminate. or at least doesn't terminate fast enough.

icy meadow
#

possibly