1

我有一个崩溃,从我的日志:

15:21:12  1645 Wrk-0.14 | *** Break ***: segmentation violation

堆栈跟踪是:

===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
...
#4  <signal handler called>
#5  0x00002b5eeef98865 in HiggsSelector::RejectBadJet (this=0x1de241a0, 
    index_jet=0, index_leading=0, index_subleading=1) at HiggsSelector.C:2375

功能是:

bool HiggsSelector::RejectBadJet(int index_jet, int index_leading, int index_subleading) const
{
    assert(index_jet >= 0);
    assert(index_leading >= 0);
    assert(index_subleading >= 0);
    assert(PV_z);
    int index_PV_ID_chosen=0; //<-----in your header
    double DiPhoton_zcommon=z_common_corrected(index_leading,index_subleading,false);
    float minimal_distance=9999;
    for (unsigned int index_PV=0;index_PV<PV_z->size()-1;index_PV++) {
      if ( fabs((*PV_z)[index_PV]-DiPhoton_zcommon)<minimal_distance) {

最后一行是数字 2375。我真的不理解这次崩溃是如何发生的,我想我已经用asserts 检查了一切。PV_z是一个*std::vector<float>

4

2 回答 2

2

如果PV_z->size() == 0,则PV_z->size()-1下溢到UINT_MAX,并且您很容易得到分段违规,因为 for 循环条件始终为真。

一种解决方法:

for (unsigned int index_PV=0; !PV_z->empty() && index_PV<PV_z->size()-1;index_PV++) {
                            //^^^^^^^^^^^^^^^^^^
于 2012-09-18T14:12:54.557 回答
1

不要丢弃 PV_z 指向的 moon,这将绕过断言。

于 2012-09-18T14:14:21.573 回答