a stack dump in llvm pass (LLVM 3.7.0)

I wrote a llvm pass:

using namespace llvm;
namespace
{
  struct CountOperands : public FunctionPass
  {
    std::map<std::string,int> opCounter;
    static char ID;

    /*Constructor*/ 
    CountOperands() : FunctionPass(ID) {}

    /*RunOnFuntion Method*/
    virtual bool runOnFunction( Function &F)
    {
      errs() << "Function Name: " << F.getName() << "\n";

      /*Reading the OpCode in the function*/
      for (Function::iterator b = F.begin(), be = F.end(); b != be; ++b)
      {    
       
        errs() << "##########Works fine "<<"\n";

        for (BasicBlock::iterator i = b.begin(), ie = b.end(); i != ie; ++i)
        {  
             errs()<<"##########Works fine till here "<<"\n";
              if(BranchInst *pBranchInst=dyn_cast<BranchInst>(i))
              {//the problem is here,there is a stack dump?why?
              }
          .....

whem I run the pass,the command is :

opt -load XX/XX.so <hello.bc> /dev/null

then I got a stack dump finally.why? could somebody help me?

The first step is to make sure you're compiling against a debug-mode
LLVM (with assertions enabled!) and actually attach a debugger.

The "dump" method prints out any IR Value and is often *very* useful
for working out where you've made an incorrect assumption in your
pass. In gdb you'd write something like "p Val->dump()" and hope for
some insight.

Your outline looks vaguely sane but by its own comments omits the
problematic section: "// the problem is here". Even a hypothetically
sane clairvoyant would struggle with that kind of delegation.

Tim.