I get this error: “glibc detected”

前端 未结 2 528
时光说笑
时光说笑 2020-12-17 00:32

I just wrote a piece of CPP code and I compiled it using G++ in ubuntu. When I run my code everything is fine, the code runs well and gives output but doesn\'t exit and it g

相关标签:
2条回答
  • 2020-12-17 00:54

    Even if you're not allocating memory directly, it happens under the hood in vector code and you most likely corrupted some portion of memory by writing where you are not supposed to. The most likely reasons I can think of are:

    1. Writing to an element that is out of bounds
    2. Using a pointer/reference to an element that is no longer valid -- note that inserting more elements can invalidate earlier references

    Of course, I can't say for sure unless you post some relevant code. Or try using valgrind to find the source of the problem.

    0 讨论(0)
  • 2020-12-17 00:55

    This means you called free on a non valid pointer (ie: a pointer not allocated via malloc, or that you already freed).

    Paste some code, else it's impossible to say why this happens.

    0 讨论(0)
提交回复
热议问题