1

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>
pb772
  • 539
  • 1
  • 3
  • 14
  • Can you provide the used network for your simulation? If you run this with the default Veins example it immediately crashes because there is no traffic light with id 0. – floxyz Mar 09 '17 at 08:35
  • Thanks for the suggestion, updated my question – pb772 Mar 09 '17 at 09:09
  • May I ask you for one more thing: Either provide a completely running example or at least provide the complete error log/stack trace when running in debug mode. – floxyz Mar 09 '17 at 09:11
  • How can I provide a completely running example? There are so many files combined that makes the program to run. I will try to run in debug mode when I have access to the computer that has the program. – pb772 Mar 09 '17 at 11:14

1 Answers1

4

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.

Julian Heinovski
  • 1,822
  • 3
  • 16
  • 27
  • Yes, I ran my simulation using valgrind and the problem is how I try to handle traci at same time I use it in `TraCIDemo11p.cc`. Do you have any idea how can I handle traci in the RSU as well? – pb772 Mar 10 '17 at 00:21
  • 1
    First of all, please post the last 2 blocks of your valgrind output file which are the summary and the block with the most memory leaks. Then try adding an assert after you assign the variables for the manager and the interface to make sure that the references are valid and you can actually invoke methods on them. – Julian Heinovski Mar 10 '17 at 01:57
  • Thanks for your concern, it was solved by removing not only the set traffic lights command line but also when I try to handle traci. `traci = manager->getCommandInterface();`. Unfortunatelly valgrind log is too complicated to understand, couldn't obtain valuable information by using it. – pb772 Mar 14 '17 at 00:38