man*_*eep 3 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
Run Code Online (Sandbox Code Playgroud)
在第294行,崩溃即将到来cout.
LdapDN是char *和不是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);
}
}
}
Run Code Online (Sandbox Code Playgroud)
崩溃_dl_fixup通常意味着您已损坏运行时加载器的状态.
两个最常见的原因是:
glibc本身不匹配的部分.如果你没有设置例如LD_LIBRARY_PATH指向非标准glibc,那么我们可以忘记理由#2.
对于#1,在Valgrind下运行程序,并确保它没有检测到错误.
如果它实际上没有,使用disas和info registersGDB命令,用他们的输出更新你的问题,你可能会收到额外的帮助.