簡體   English   中英

我在Netbeans上得到了這些隨機的段錯誤

[英]I get these random seg faults on netbeans

我在做c ++,代碼給了我這些錯誤:

   new size of the done 64
   getting next item to do (0x90b9c0 0x90bab0 0x90be40 0)
   vector wait size = 0
   running size = 1
   done size = 64
   done this align #27# #26# Gorilla_gorilla_2
   setting the done tuple to 1 to get them next
   new size of the done 65
   getting next item to do (0xbff3897200000000 0xbfda1b75f84c0030 0x30 17)
   vector wait size = 18446744073709551615
   running size = 1
   done size = 65
   getting next item to do (0xbfdcc288867fc50b 0x31 0x1 1)
   /usr/local/netbeans-7.2rc1/ide/bin/nativeexecution/dorun.sh: line 33:  8234   
   Segmentation     
   fault      (core dumped) sh "${SHFILE}"

而且我想知道如何才能得到更多有關段錯誤的詳細信息,例如引起該錯誤的線路,以解決該問題,謝謝。

編輯:

  bool tuple_compare(boost::tuple< ppa::Node*, ppa::Node*, ppa::Node*, bool> tuple)
{



  if( boost::get< 3 >( tuple) == true)
 {
          return true;
 }
  else
  {
      return false;
  }
 }


void threaded_function(Model_factory &mf, ppa::Node *root)
 {
  try {


  while(true)
  {
      boost::mutex::scoped_lock lock(result_mutex);

      if(wait.empty())
      {

          lock.unlock();
          break;
      }
      else {
          lock.unlock();
          lock.lock();
          if(!running_jobs.empty())
          {
              cout << "vector wait size = " << wait.size() << endl;
              cout << "running size = " << running_jobs.size() << endl;
              cout << "done size = " << done.size() << endl;
              boost::tuple<ppa::Node*, ppa::Node*, ppa::Node*, bool> tuple = running_jobs.back();
              running_jobs.pop_back();
              lock.unlock();
              ppa::Node *father = boost::get<0>(tuple);
              ppa::Node *first_son = boost::get<1>(tuple);
              ppa::Node *second_son = boost::get<2>(tuple);
              bool flag = boost::get<3>(tuple);
              father->start_alignment_new(&mf);
              lock.lock();
              cout << "done this align " << father->get_name() << " " << first_son->get_name() << " " << second_son->get_name()
                      << endl;
              cout << "setting the done tuple to 1 to get them next" << endl;
              done.push_back(tuple);
              cout << "new size of the done " << done.size() << endl;
              lock.unlock();



          }
          else {
              lock.unlock();
              lock.lock();
              cout << "getting next item to do " << wait.back() << endl;
              boost::tuple<ppa::Node*, ppa::Node*, ppa::Node*, bool> run = wait.back();
              running_jobs.push_back(run);
              wait.pop_back();
              lock.unlock();
          }
      }
    }
  }
  catch (boost::lock_error& le)
  {
      cout << "error this " << le.what() << endl;
  }
  }

主要:

 int main(int argc, char *argv[])
 {
clock_t t_start=clock();
ppa::Node* parent;
ppa::Node* left;
ppa::Node* rigth;
ppa::Node* check_root;
/*

...

boost::tuple<ppa::Node*, ppa::Node*, ppa::Node*, bool>  tuple = dups.back();
    ppa::Node *n = boost::get<0>(tuple);
     //cout << "creating waiting thread" << endl;
   // g.create_thread( boost::bind(wait_function));
    cout << "creating other threads" << endl;
 for ( int i = 0; i < 5; ++i )
 {
   cout << "making  thread " << i << endl;
    g.create_thread( boost::bind( threaded_function, boost::ref(mf), boost::ref(n) ));
}



 cout << g.size() << endl ;
// wait for them
// sleep(15);
 g.join_all();     

我很確定這是我添加的新內容。

錯誤的代碼,太多的鎖定和解鎖,互斥體具有一種鎖定方法,無需使用共享的lock.lock()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM