Valgrind reporting “brk segment overflow in thread

2019-06-18 18:36发布

问题:

This question already has an answer here:

  • Valgrind reporting a segment overflow 5 answers

I wonder what this message implies:

==18151== brk segment overflow in thread #1: can't grow to 0x4a26000

Note that the code runs just fine and the output is correct. Should I just ignore this message? And what does it mean?

回答1:

I think you can ignore it. I got the message in a new allocation in some code that seemed to work perfectly and I also get the message it in the following code:

#include <vector>

struct Something
{
    Something() : a1(0), b1(0) { }
    unsigned short a1;
    unsigned short b1;
};

const int allocsize = 10000;

struct Tester
{
   Tester()
   {
       for (int u = 0; u < allocsize; ++u)
           data.push_back(new Something[519]);
   }

   ~Tester()
   {
       for (int u = 0; u < allocsize; ++u)
           delete[] (data[u]);
   }

   std::vector<Something*> data;
};

void test()
{
     Tester t;
     // while (true) {;}
}

int main()
{
    test();
    return 0; 
}

I also noticed that others experience the same issue:

Valgrind reporting a segment overflow



标签: c++ valgrind