https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70403
Bug ID: 70403 Summary: A null pointer check removed with -O2 even with -fno-delete-null-pointers-checks Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: thadula at ciena dot com Target Milestone: --- g++, powerpc-e500-linux-gnuspe-g++, version 4.9.2 compiled with -O2 and -fno-delete-null-pointers-checks Code (look for ==> to mark the point in the code): static const char* fnName = "NewLs::CpSelect - "; tbr_t tbrStart, tbrEnd, timediff; tbrStart = tbrGet(); McId newCpId((McIdHandle)cpId); McId newSelId((McIdHandle)selId); McCpId* pCpId = static_cast<McCpId*>(&newCpId); ComplexXCon* pXCon = NULL; CtpCpBase* pNewSel = NULL; ComplexXCon* pNewXCon = NULL; UniCp* pCp = NULL; rFailureReason = LS_SUCCESS; if (!pCpId) { MEMORY_LOG_MCHECK (getSwitchCoreMemoryLog(), pCpId, NULL, "!!!ERROR!!!: " << fnName << "null CP id"); return false; } // Find the CP object pCp = FindCpFromHashList(*pCpId); if (!pCp) { LOGIC_SWITCH_ERRLOG_PRINTF (getSwitchCoreMemoryLog(), "%sCannot find CP 0x%llX", fnName, cpId); rFailureReason = END_POINT_NOT_FOUND; return false; } McCpProtectionApp protApp = pCp->GetProtApp(); if (rxProtApp != protApp) { . . . return false; } pXCon = pCp->GetXCon(); if (!pXCon) { char mcBuf[ 64 ]; pCpId->toString (mcBuf, sizeof (mcBuf)); LOGIC_SWITCH_ERRLOG_PRINTF (getSwitchCoreMemoryLog(), "%sCannot find XCon for CP: %s", fnName, mcBuf); rFailureReason = CROSS_CONNECT_NOT_FOUND; return false; } if (!squelch) { if (newSelId == McId::InvalidId) { rFailureReason = BAD_END_POINT_ID; return false; } // // Find the CTP or CP (if it exists) and verify that it belongs to pXCon // if (newSelId.IsCtpId()) { McCtpId ctpId(newSelId); pNewSel = FindCtpFromHashList(ctpId); } else if (newSelId.IsCpId()) { McCpId newCpId((McCpIdHandle) newSelId.GetId()); pNewSel = FindCpFromHashList(newCpId); } ==> if (pNewSel) pNewXCon = pNewSel->GetXCon(); } else { char mcBuf[ 64 ]; pCpId->toString (mcBuf, sizeof (mcBuf)); getSwitchCoreMemoryLog()->PrintRamLog ("%sSetting %s to be squelched.", fnName, mcBuf); } if (squelch || (pNewSel && pNewXCon == pXCon)) { if (pCp->GetSelectedCtpCp() == pNewSel || (isDefaultFromCac && pCp->GetDefaultSelector() == pNewSel)) { . . . return false; // already selected } // Update current selector on CP. pCp->SetSelectedCtpCp(pNewSel); . . . } Segmentation fault: Program terminated with signal 11, Segmentation fault. #0 CtpCpBase::GetXCon (this=this@entry=0x0) at src/software/centaur/apps/core/txn/Switching/NewLS/CtpCpBase.cpp:79 79 if( mpXCon && mpXCon->IsRemoteTAP() && !mpXCon->IsRemoteTAPParent() ) (gdb) bt #0 CtpCpBase::GetXCon (this=this@entry=0x0) at src/software/centaur/apps/core/txn/Switching/NewLS/CtpCpBase.cpp:79 #1 0x1149b610 in NewLogicalSwitch::CpSelect (this=0x671d0038, cpId=<optimized out>, selId=<optimized out>, rFailureReason=@0x7019e6f0: LS_SUCCESS, rxProtApp=rxProtApp@entry=MC_CP_PROTECTION_APP_UPSR_SNCP, squelch=true, isDefaultFromCac=isDefaultFromCac@entry=false) at src/software/centaur/apps/core/txn/Switching/NewLS/NewLogicalSwitch.cpp:8221 #2 0x1149bfb4 in NewLogicalSwitch::CpSelectTest (this=<optimized out>, cpId=cpId@entry=2, newSelId=<optimized out>) at src/software/centaur/apps/core/txn/Switching/NewLS/NewLogicalSwitch.cpp:5869 #3 0x114c704c in NewLsDcraft::ImplementMsg (this=0x6df9b338, pObj=0x836ea7e8) at src/software/centaur/apps/core/txn/Switching/NewLS/NewLsDcraft.cpp:711 #4 0x11cafe6c in Actor::Run (this=0x6df9b338) at src/generic/component/Actor/Actor.cpp:929 #5 0x11bdff9c in RunnableTask::TaskFunction (this=0x6df9c970) at src/generic/component/UtilProg/RunnableTask.cpp:35 #6 0x11593080 in LnTask::TaskEntry (pThis=0x6df9c970) at src/generic/component/Osencap/linux/LnTask.cpp:627 #7 0x0f1ecc04 in ?? () #8 0x09e4a5b4 in ?? () (gdb) up #1 0x1149b610 in NewLogicalSwitch::CpSelect (this=0x671d0038, cpId=<optimized out>, selId=<optimized out>, rFailureReason=@0x7019e6f0: LS_SUCCESS, rxProtApp=rxProtApp@entry=MC_CP_PROTECTION_APP_UPSR_SNCP, squelch=true, isDefaultFromCac=isDefaultFromCac@entry=false) at src/software/centaur/apps/core/txn/Switching/NewLS/NewLogicalSwitch.cpp:8221 8221 pNewXCon = pNewSel->GetXCon(); (gdb) p pNewXcon No symbol "pNewXcon" in current context. (gdb) p pNewXCon $1 = (ComplexXCon *) 0x0 (gdb) p pNewSel $2 = (CtpCpBase *) 0x0 (gdb) disassemble Dump of assembler code for function NewLogicalSwitch::CpSelect(unsigned long long, unsigned long long, RStatus&, McCpProtectionApp, bool, bool): 0x1149b494 <+0>: stwu r1,-448(r1) 0x1149b498 <+4>: mflr r0 0x1149b49c <+8>: bcl- 20,4*cr7+so,0x1149b4a0 <NewLogicalSwitch::CpSelect(unsigned long long, unsigned long long, RStatus&, McCpProtectionApp, bool, bool)+12> 0x1149b4a0 <+12>: li r11,0 0x1149b4a4 <+16>: stw r30,440(r1) 0x1149b4a8 <+20>: mflr r30 0x1149b4ac <+24>: stw r0,452(r1) 0x1149b4b0 <+28>: lwz r0,-16(r30) 0x1149b4b4 <+32>: stw r21,404(r1) 0x1149b4b8 <+36>: stw r18,392(r1) 0x1149b4bc <+40>: add r30,r0,r30 0x1149b4c0 <+44>: stw r19,396(r1) 0x1149b4c4 <+48>: lwz r21,-32608(r30) 0x1149b4c8 <+52>: mr r19,r3 0x1149b4cc <+56>: stw r20,400(r1) 0x1149b4d0 <+60>: mr r20,r9 0x1149b4d4 <+64>: stw r24,416(r1) 0x1149b4d8 <+68>: mr r24,r7 0x1149b4dc <+72>: lbz r10,0(r21) 0x1149b4e0 <+76>: stw r25,420(r1) 0x1149b4e4 <+80>: mr r25,r8 0x1149b4e8 <+84>: stw r26,424(r1) 0x1149b4ec <+88>: mr r26,r5 0x1149b4f0 <+92>: cmpwi cr7,r10,0 0x1149b4f4 <+96>: stw r27,428(r1) 0x1149b4f8 <+100>: stw r22,408(r1) 0x1149b4fc <+104>: mr r27,r6 0x1149b500 <+108>: stw r23,412(r1) 0x1149b504 <+112>: stw r28,432(r1) 0x1149b508 <+116>: stw r29,436(r1) 0x1149b50c <+120>: stw r31,444(r1) 0x1149b510 <+124>: lbz r18,463(r1) 0x1149b514 <+128>: stw r11,376(r1) 0x1149b518 <+132>: stw r11,380(r1) 0x1149b51c <+136>: bne- cr7,0x1149b698 <NewLogicalSwitch::CpSelect(unsigned long long, unsigned long long, RStatus&, McCpProtectionApp, bool, bool)+516> 0x1149b520 <+140>: bl 0x1159415c <tbrGet()> 0x1149b524 <+144>: lwz r29,-32576(r30) 0x1149b528 <+148>: li r9,0 0x1149b52c <+152>: addi r28,r1,264 0x1149b530 <+156>: stw r9,0(r20) 0x1149b534 <+160>: mr r23,r4 ---Type <return> to continue, or q <return> to quit--- 0x1149b538 <+164>: mr r22,r3 0x1149b53c <+168>: mr r4,r28 0x1149b540 <+172>: addi r3,r1,360 0x1149b544 <+176>: stw r29,360(r1) 0x1149b548 <+180>: li r5,64 0x1149b54c <+184>: stw r26,368(r1) 0x1149b550 <+188>: stw r27,372(r1) 0x1149b554 <+192>: stw r29,344(r1) 0x1149b558 <+196>: stw r24,352(r1) 0x1149b55c <+200>: stw r25,356(r1) 0x1149b560 <+204>: bl 0x11389960 <McId::toString(char*, unsigned int) const> 0x1149b564 <+208>: addi r24,r1,344 0x1149b568 <+212>: addi r31,r1,200 0x1149b56c <+216>: mr r3,r24 0x1149b570 <+220>: mr r4,r31 0x1149b574 <+224>: li r5,64 0x1149b578 <+228>: bl 0x11389960 <McId::toString(char*, unsigned int) const> 0x1149b57c <+232>: bl 0x117fad3c <getSwitchCoreMemoryLog()> 0x1149b580 <+236>: lwz r4,-31828(r30) 0x1149b584 <+240>: mr r5,r28 0x1149b588 <+244>: mr r6,r31 0x1149b58c <+248>: crclr 4*cr1+eq 0x1149b590 <+252>: bl 0x11273d8c <MemoryLog::PrintRamLog(char const*, ...)> 0x1149b594 <+256>: lwz r25,-32164(r30) 0x1149b598 <+260>: mr r31,r1 0x1149b59c <+264>: lwz r10,368(r1) 0x1149b5a0 <+268>: mr r3,r19 0x1149b5a4 <+272>: lwz r11,372(r1) 0x1149b5a8 <+276>: stw r10,16(r1) 0x1149b5ac <+280>: stw r11,20(r1) 0x1149b5b0 <+284>: stwu r25,8(r31) 0x1149b5b4 <+288>: mr r4,r31 0x1149b5b8 <+292>: bl 0x11495e2c <NewLogicalSwitch::FindCpFromHashList(McCpId)> 0x1149b5bc <+296>: mr. r28,r3 0x1149b5c0 <+300>: beq- 0x1149b6b0 <NewLogicalSwitch::CpSelect(unsigned long long, unsigned long long, RStatus&, McCpProtectionApp, bool, bool)+540> 0x1149b5c4 <+304>: bl 0x114ce120 <UniCp::GetProtApp() const> 0x1149b5c8 <+308>: mr r27,r3 0x1149b5cc <+312>: mr r3,r28 0x1149b5d0 <+316>: bl 0x114e671c <CtpCpBase::GetXCon() const> 0x1149b5d4 <+320>: lwz r10,352(r1) 0x1149b5d8 <+324>: mr r26,r3 0x1149b5dc <+328>: lwz r9,356(r1) 0x1149b5e0 <+332>: cmpwi cr7,r10,0 0x1149b5e4 <+336>: beq- cr7,0x1149b744 <NewLogicalSwitch::CpSelect(unsigned long long, unsigned long long, RStatus&, McCpProtectionApp,---Type <return> to continue, or q <return> to quit--- bool, bool)+688> 0x1149b5e8 <+340>: andis. r8,r9,32768 0x1149b5ec <+344>: bne- 0x1149bb14 <NewLogicalSwitch::CpSelect(unsigned long long, unsigned long long, RStatus&, McCpProtectionApp, bool, bool)+1664> 0x1149b5f0 <+348>: mr r3,r19 0x1149b5f4 <+352>: stw r8,16(r1) 0x1149b5f8 <+356>: mr r4,r31 0x1149b5fc <+360>: stw r9,20(r1) 0x1149b600 <+364>: stw r25,8(r1) 0x1149b604 <+368>: bl 0x11495e2c <NewLogicalSwitch::FindCpFromHashList(McCpId)> 0x1149b608 <+372>: mr r29,r3 0x1149b60c <+376>: bl 0x114e671c <CtpCpBase::GetXCon() const> => 0x1149b610 <+380>: mr r3,r28 0x1149b614 <+384>: bl 0x114e6748 <CtpCpBase::GetSelectedCtpCp() const> 0x1149b618 <+388>: cmpw cr7,r29,r3 0x1149b61c <+392>: beq- cr7,0x1149b76c <NewLogicalSwitch::CpSelect(unsigned long long, unsigned long long, RStatus&, McCpProtectionApp, bool, bool)+728> 0x1149b620 <+396>: cmpwi cr7,r18,0 0x1149b624 <+400>: bne- cr7,0x1149b75c <NewLogicalSwitch::CpSelect(unsigned long long, unsigned long long, RStatus&, McCpProtectionApp, bool, bool)+712>