RoboSherlock / robosherlock

http://www.robosherlock.org
26 stars 28 forks source link

Adding simple data to a CAS / SceneCAS::get() crashes #87

Open Sanic opened 7 years ago

Sanic commented 7 years ago

As discussed with @bbferka, how can i add a simple test string to the CAS do use it across different Annotators?

rs::SceneCas scas(tcas);
rs::Annotation someAnnotation = rs::create<rs::Annotation>(tcas);
std::string someStr("mytest");
someAnnotation.source.set(someStr);
someAnnotation.source.get(); // <- This call works
scas.set("example", someAnnotation);

// Read back for verification
rs::Annotation testAnno = rs::create<rs::Annotation>(tcas);
scas.get("example", testAnno);
testAnno.source.get(); // <- This call crashes

This is the error message:

Program received signal SIGSEGV, Segmentation fault.
uima::FeatureStructure::isValid (
    this=0x7ffff7b16db4 <uima::FeatureStructure::getStringValue(uima::Feature const&) const+20>, 
    this@entry=0x7fffffffc5f0) at ../cas/featurestructure.cpp:237
237        return iv_tyFS != 0 && ( iv_cas->getHeap()->isValid(iv_tyFS));

As @bbferka pointed out, a quick fix for this seems to be to use getFS() instead of get() in the second code block. But why is get() crashing?

jworch commented 7 years ago

I remember having a similar problem when adding rs::human (which is of type identifiable)

cas.set(VIEW_HUMAN, *m_skeleton);
// If access to rs::Human is needed use this instead of the struct:
//    uima::FeatureStructure fs;
//    if(!cas.getFS(VIEW_HUMAN, fs))
//    {
//      outInfo("No Humans detected. Nothing to broadcast.");
//      return;
//    }
//    rs::Human human2(fs);
//    std::vector<rs::Joint2D> joints2d = human2.joints2D();
//    std::vector<rs::Joint3D> joints3d = human2.joints3D();
//    outInfo(joints2d.at(0).position().x());
//    outInfo(joints3d.at(0).position().x());

//... otherwise access the struct this way:
//        struct skeletonHuman human2;
//        if(!cas.get(VIEW_HUMAN, human2))
//        {
//          outInfo("No Humans detected. Nothing to broadcast.");
//          return;
//        }
//        outInfo(human2.joint2D[0].x);
//        outInfo(human2.joint3D[0].x);

Back then we tried to identify the problem, but (due to being short in time) we stopped investigating this any further.

Might be worth having a look at it again.

jworch commented 7 years ago

We just did some experiments. Have a look at: 730736eccfa5b92811d604f1d1105f544db95490

For some strange reason it works....

bbferka commented 7 years ago

Using 730736eccfa5b92811d604f1d1105f544db95490 does not fix it for me. Using getFS solves this issue for now. I'll leave the issue open and hopefully we'll have the time to look at this in more detail.