[gecode-users] Views and serialization

Guido Tack tack at ps.uni-sb.de
Sat Nov 24 08:35:53 CET 2007


Gustavo Gutierrez wrote:

> I am getting some memory errors after the suggested modification. I
> get a "bus error" which is, IMO, the equivalent to segmentation fault
> in linux. It seems that the fresh VarMap, vm_target, is causing the
> problem. After looking at test/int.cc i see that before using the
> fresh VarMap the array of variables is registered. Then i have the
> following question: What is registerArray intended for?, and what is
> the difference with putArray?. I try to call this method before actor
> iteration but the error is still there.

The difference between putArray and registerArray is that  
registerArray just introduces the name->VarBase* mapping into the  
VarMap, whereas putArray also assigns an integer index to the  
variable.  All references to variables (e.g. in the ActorSpecs) are by  
index only.  If you used putArray in vm_target, all the variables  
would already get assigned these indexes, but their indexes would not  
necessarily be the same as in vmp.

Another thing I just noticed now is that vmp should come from the  
source, not the target:

void merge(Queens *target, Queens *source) {
   VarMap *vmp = source->exportVars();
   Reflection::SpecIter si = source->actorSpecs(*vmp);

   VarMap vm_target;
   Gecode::Serialization::Deserializer ds(target, vm_target);

   while (si()) {
     ds.post(si.actor());
     ++si;
   }
}

I'm not sure that explains the crash.  One thing that might explain it  
is a bug that I found this week, which may make VarMaps crash under  
certain conditions.  It's fixed in the Gecode trunk, but didn't make  
it into 2.0.0.
If you can't get it to work, please send me the complete source code  
that crashes (by private email), I'll have a look.

Cheers,
	Guido





More information about the gecode-users mailing list