Std::vector::push_back segmentation violation

I got a segmentation violation using proof

pointer OK
ienergy: 0
adding energy 5000       <---------------- last cout from SlaveBegin
00:29:14  2144 Wrk-0.1 | *** Break ***: segmentation violation

when calling std::vector::push_back

#5  <signal handler called>
#6  0x00002aaaac07eba6 in CalibrationSelector::InitOptions (
    this=0x2aaab08d4280)
    at /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h:104
#7  0x00002aaaadfdac99 in HistoFillingProof::SlaveBegin ()
   from /proof/workingdirs/turra/session-t2-wn-11-1300318142-16040/worker-0.1-t2-wn-10-1300318143-2144/./HistoFillingProof_C.so
#8  0x00002aaaadd31e14 in TProofPlayer::Process ()
   from /gpfs/storage_4/users/home/proof/root/lib/libProofPlayer.so
#9  0x00002b6ce2f9a972 in TProofServ::HandleProcess ()
   from /gpfs/storage_4/users/home/proof/root/lib/libProof.so

the line of code that generate the error are in a function called by SlaveBegin() and the vector they fill is a public data member:

    TH1I* particle_energies_histo = dynamic_cast<TH1I*>(fInput->FindObject("particle_energies"));
    if (!particle_energies_histo)
    {
	cerr << "particle_energies = 0" << endl;
	assert(false);
    }
    else { cout << "pointer OK" << endl; }
    for (int ienergy = 0; ienergy <= particle_energies_histo->GetNbinsX() + 1; ++ienergy)
    {
	cout << "ienergy: " << ienergy << endl;
	cout << "adding energy " << particle_energies_histo->At(ienergy) << endl;
	energies.push_back(particle_energies_histo->At(ienergy));
    }

I used std::vectors for a long time, and I’ve never found a similar problem

it is very weird, I’ve changed a bit the code (nothing related to that function) and not it works perfectly…

You must have a problem somewhere else.
The attached code works perfectly.
testWiso.tar.gz (3.15 KB)

[quote=“ganis”]You must have a problem somewhere else.
The attached code works perfectly.[/quote]

thanks, I’m sure I’ve another problem somewhere else, the question is why the bracktrace says I’ve a problem allocating a new element in a std::vector.