<i id='YtBN1'><tr id='YtBN1'><dt id='YtBN1'><q id='YtBN1'><span id='YtBN1'><b id='YtBN1'><form id='YtBN1'><ins id='YtBN1'></ins><ul id='YtBN1'></ul><sub id='YtBN1'></sub></form><legend id='YtBN1'></legend><bdo id='YtBN1'><pre id='YtBN1'><center id='YtBN1'></center></pre></bdo></b><th id='YtBN1'></th></span></q></dt></tr></i><div id='YtBN1'><tfoot id='YtBN1'></tfoot><dl id='YtBN1'><fieldset id='YtBN1'></fieldset></dl></div>

      <tfoot id='YtBN1'></tfoot>

    1. <small id='YtBN1'></small><noframes id='YtBN1'>

      <legend id='YtBN1'><style id='YtBN1'><dir id='YtBN1'><q id='YtBN1'></q></dir></style></legend>
        <bdo id='YtBN1'></bdo><ul id='YtBN1'></ul>
    2. malloc() 和 malloc_consolidate() 中的段错误

      时间:2023-05-23
      <i id='X2fxk'><tr id='X2fxk'><dt id='X2fxk'><q id='X2fxk'><span id='X2fxk'><b id='X2fxk'><form id='X2fxk'><ins id='X2fxk'></ins><ul id='X2fxk'></ul><sub id='X2fxk'></sub></form><legend id='X2fxk'></legend><bdo id='X2fxk'><pre id='X2fxk'><center id='X2fxk'></center></pre></bdo></b><th id='X2fxk'></th></span></q></dt></tr></i><div id='X2fxk'><tfoot id='X2fxk'></tfoot><dl id='X2fxk'><fieldset id='X2fxk'></fieldset></dl></div>

        <small id='X2fxk'></small><noframes id='X2fxk'>

        • <bdo id='X2fxk'></bdo><ul id='X2fxk'></ul>

            <tfoot id='X2fxk'></tfoot>

                <tbody id='X2fxk'></tbody>

              1. <legend id='X2fxk'><style id='X2fxk'><dir id='X2fxk'><q id='X2fxk'></q></dir></style></legend>

              2. 本文介绍了malloc() 和 malloc_consolidate() 中的段错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                当我查看 gdb 中的回溯时,我的应用程序有时会出现段错误,主要是在 malloc() 和 malloc_consolidate() 中.

                My application segfaults sometimes and mainly in malloc() and malloc_consolidate() when I look at the backtrace in gdb.

                我确认机器有足够的可用内存,它甚至没有开始交换.我检查了数据段的 ulimits 和最大内存大小,两者都设置为无限制".我也在 valgrind 下运行该应用程序,没有发现任何内存错误.

                I verified that the machine has enough memory available, it didn't even start swapping. I checked ulimits for data segement and max memory size and both are set to 'unlimited'. I also ran the application under valgrind and didn't find any memory errors.

                现在我不知道还有什么可能导致这些段错误.有什么想法吗?

                Now I'm out of ideas what else might be causing these segfaults. Any Ideas ?

                更新:由于我没有找到任何与 valgrind(或 ptrcheck)有关的东西,是不是另一个应用程序正在破坏 libc 的内存结构,还是每个进程都有一个单独的结构?

                Update: Since I'm not finding anything with valgrind (or ptrcheck), could it be that another application is trashing libc's memory structure or is there a separate structure for each process ?

                推荐答案

                来自 http://www.gnu.org/s/libc/manual/html_node/Heap-Consistency-Checking.html#Heap-Consistency-Checking:

                检查和防范使用中的错误的另一种可能性malloc、realloc和free是设置环境变量MALLOC_CHECK_.当 MALLOC_CHECK_ 被设置时,一个特殊的(效率较低的)使用了旨在容忍简单的实现错误,例如使用相同参数两次调用 free,或单个字节的溢出(逐一错误).并非所有此类错误都可以但是,可能会导致内存泄漏.如果MALLOC_CHECK_ 设置为 0,任何检测到的堆损坏都是静默的忽略;如果设置为 1,则在 stderr 上打印诊断信息;如果设置为 2,立即调用 abort.这可能很有用,因为否则崩溃可能发生得更晚,问题的真正原因是然后很难追查.

                Another possibility to check for and guard against bugs in the use of malloc, realloc and free is to set the environment variable MALLOC_CHECK_. When MALLOC_CHECK_ is set, a special (less efficient) implementation is used which is designed to be tolerant against simple errors, such as double calls of free with the same argument, or overruns of a single byte (off-by-one bugs). Not all such errors can be protected against, however, and memory leaks can result. If MALLOC_CHECK_ is set to 0, any detected heap corruption is silently ignored; if set to 1, a diagnostic is printed on stderr; if set to 2, abort is called immediately. This can be useful because otherwise a crash may happen much later, and the true cause for the problem is then very hard to track down.

                这篇关于malloc() 和 malloc_consolidate() 中的段错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:“跨过"在 Visual Studio 中调试多线程程序时 下一篇:在 Visual Studio 调试中检查 STL 容器

                相关文章

                最新文章

                      <bdo id='9qC6c'></bdo><ul id='9qC6c'></ul>

                    <small id='9qC6c'></small><noframes id='9qC6c'>

                    <tfoot id='9qC6c'></tfoot>

                    <legend id='9qC6c'><style id='9qC6c'><dir id='9qC6c'><q id='9qC6c'></q></dir></style></legend>

                    <i id='9qC6c'><tr id='9qC6c'><dt id='9qC6c'><q id='9qC6c'><span id='9qC6c'><b id='9qC6c'><form id='9qC6c'><ins id='9qC6c'></ins><ul id='9qC6c'></ul><sub id='9qC6c'></sub></form><legend id='9qC6c'></legend><bdo id='9qC6c'><pre id='9qC6c'><center id='9qC6c'></center></pre></bdo></b><th id='9qC6c'></th></span></q></dt></tr></i><div id='9qC6c'><tfoot id='9qC6c'></tfoot><dl id='9qC6c'><fieldset id='9qC6c'></fieldset></dl></div>