Why I get an error code 139 if I run this code?

一个人想着一个人 提交于 2019-12-08 11:17:01

问题


I would like to know why I can build this project, but as soon as RSU receives the message I get an error 139. Even if I try to solve by removing the code inserted in onData function and run the project again, still doesn't work.

TraCIDemoRSU11p.h

TraCIScenarioManager* manager;
TraCICommandInterface* traci;

TraCIDemoRSU11p.cc

void TraCIDemoRSU11p::initialize(int stage) 
{
    BaseWaveApplLayer::initialize(stage);
    if (stage == 0) {
        manager = TraCIScenarioManagerAccess().get();
        traci = manager->getCommandInterface();
        traci->trafficlight("0").setProgram("tram_is_not_passing");
    }
}


void TraCIDemoRSU11p::onData(WaveShortMessage* wsm) 
{
    traci->trafficlight("0").setProgram("tram_is_passing");
}

veins version is 4.4 and omnet++ version is 5. I think the problem might be how I got traci interface in the initialize function, can anyone please explain how two modules use traci interface at the same time?

Edit:

As requested I am adding more information to the question.

Cross.net.xml

....
<tlLogic id="0" type="static" programID="1" offset="0">
    <phase duration="500" state="rGrG"/>
</tlLogic>
....

Cross.tls.xml

<tls>  
    <tlLogic id="0" type="static" programID="tram_is_passing" offset="0">
        <phase duration="4" state="ryry"/>
        <phase duration="20" state="GrGr"/>
    </tlLogic>

    <tlLogic id="0" type="static" programID="tram_is_not_passing" offset="0">
        <phase duration="999" state="rGrG"/>
    </tlLogic>
</tls>

回答1:


As far as I know, OMNeT++ starts at 128 with its error codes and than adds the normal system error codes. This means that 139 = 128 + 11 and 11 is the error code for a segmentation fault.

Hence, it seems you are trying to use memory space which is not allocated or you are not allowed to use. You should run you simulation with Valgrind using ./memcheck to find out whether you have memory leaks.

EDIT: After Veins 4.7.1 a new run script was introduced. Now you can run your simulation with Valgrind using ./run -t memcheck.



来源:https://stackoverflow.com/questions/42687116/why-i-get-an-error-code-139-if-i-run-this-code

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!