Ok. I got that to work. However, I've got another problem when executing the program in parallel with Intel TBB.
I have some child classes that will simulate the events between particles in a particle system and compute the next event for each particle in parallel. Once the child classes have finished, a continuation class will check if there are conflicts between them and update the global system.
The problem is in the code of the child class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
HitEventAux* ParticleTask::LocalZoneEvent(
Particle* restrict P,
const Zone* z
) throw (
NotEnoughMemoryException
) {
try {
return new HitEventAux( z->PossibleEvent( P ) );
} catch( const std::bad_alloc& e ) {
throw NotEnoughMemoryException( "Auxiliar event", __FILE__, __LINE__ );
}
}
void ParticleTask::CheckNextEvent(
Particle* owner,
Particle* partner,
const Zone* z,
HitEventAux* &toret
) {
toret = LocalZoneEvent( owner, z );
unsigned int partner_index( ETERNITY );
if( partner ) {
partner_index = partner->Index();
}
const Zone::iterator end_it(z->end());
for(Zone::iterator
it(z->whereIs( owner->Index() ) );
it!=end_it;
++it
) {
Hitable* restrict N=*it;
if(
N->Index() != owner->Index()
&& N->Index() != partner_index
) { // neither hit yourself, nor your last partner
const HitEvent next_event( N->PossibleEvent( owner, *z, it ) );
if( next_event.Time() <= toret->Time() ) {
toret->SetOwner( next_event.Owner()->Index() );
toret->SetType( next_event.Type() );
toret->SetTime( next_event.Time() );
if( next_event.Partner() ) {
toret->SetPartner( next_event.Partner()->Index() );
} else {
toret->SetPartner( ETERNITY );
}
}
}
}
|
The line where the segfault occurs is
const HitEvent next_event( N->PossibleEvent( owner, *z, it ) )
.
When debugging, I wanted to check the value of
N, to see if it was a null pointer; but ended with this:
warning: can't find linker symbol for virtual table for `Hitable' value
In Google I couldn't find anything useful and that warning only occurs when the program segfaults, which is always when checking the 2006th and 2007th events.
Before those two, when placing a breakpoint at that line and checking the contents of
N, everything goes well(the other args:
owner,
z and
it are fine).
The thing is that I need to check the content of
N to debug the code, but with that warning is impossible. Any help?.
Thanks!
PS: I have tried to run the program using the TBB library, simulating only one event at a time and using only one thread(basically, a serial execution) and it goes perfectly. No warnings, no segfaults.
PS2: A particle is derived form
Hitable and
toret is declared before calling the method as a NULL pointer. It is intended to be initialized by the LocalZoneEvent method. Don't know if that helps...