c++ - _dl_runtime_resolve() 中的段错误

标签 c++ linux crash segmentation-fault

我在代码中执行简单的字符串操作时遇到了段错误。我不知道确切的问题是什么。 请看看是否有人可以提供帮助。

核心的回溯是

(gdb) bt
#0  0x00007f595dee41da in _dl_fixup () from /lib64/ld-linux-x86-64.so.2
#1  0x00007f595deea105 in _dl_runtime_resolve () from /lib64/ld-linux-x86-64.so.2
#2  0x0000000000401d04 in getNodeInfo (node=0x7fffbfb4ba83 "TCU-0")
    at hwdetails.cpp:294
#3  0x0000000000402178 in main (argc=3, argv=0x7fffbfb4aef8)
    at hwdetails.cpp:369

第 294 行,崩溃发生在 cout 语句所在的位置。
LdapDNchar * 并且不是 NULL

if ( Epath && (Epath->Entry[0].EntityType == SAHPI_ENT_UNSPECIFIED ||
         Epath->Entry[0].EntityType == SAHPI_ENT_ROOT )) {
        // nothing is mapped. Degrade the ldap dn path to slot.
        if(LdapDN){
            std::cout << "LdapDN " << LdapDN << std::endl;
        }
        std::string ldapDN;
        ldapDN = LdapDN;
        std::string slot = LDAP_PIU_ID;
        if ( ldapDN.compare(0, slot.length(), slot) != 0 ) {
            size_t pos = ldapDN.find(slot);
            if ( pos != std::string::npos ) {
                ldapDN = ldapDN.substr(pos);
                LdapDN = (char *)ldapDN.c_str();
                //getEntityPathFromLdapDn(ldapDN.c_str(), epath, domid);
            }
        }
     }

最佳答案

_dl_fixup 中的崩溃通常意味着您已经破坏了运行时加载程序的状态。

两个最常见的原因是:

  1. 堆损坏(溢出)或
  2. glibc 本身的不匹配部分。

如果您没有设置例如LD_LIBRARY_PATH 指向一个非标准的 glibc,那么我们就可以忘记原因 #2。

对于 #1,在 Valgrind 下运行您的程序,并确保它没有检测到错误。

如果事实并非如此,请使用 disasinfo registers GDB 命令,用它们的输出更新您的问题,您可能会得到额外的帮助。

关于c++ - _dl_runtime_resolve() 中的段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10578315/

相关文章:

c++ - 在 C++ 中读取 json 文件

c++ - 我可以在 Qt 应用程序中使用现有的 native Windows COM 接口(interface)吗

linux - 如何检查 perl 脚本中的管道数据

linux - 如何压缩有大小限制的文件?

c++ - Cocos2d-x 3.7 C++ CCLoad UIPageView 崩溃

c++ - iterator 和 back_insert_iterator 有什么区别?

linux - 如何删除 bash 中包含任何匹配文本的行

python - 调试 Python fatal error : GC Object already Tracked

ios 应用程序在启动时发生奇怪的崩溃

c++ - ofstream线程安全吗?