iocchi / PetriNetPlans

Petri Net Plans library and applications
31 stars 15 forks source link

pnpgen_linear segfault when applying execution rules to actions without duration #11

Closed cdondrup closed 8 years ago

cdondrup commented 8 years ago

To circumvent the issue in #10 and test the execution rules, I tried to remove the durations from my linear plan. This now simply looks like this:

goto_forward; say_hello

with the execution rule

*if* failed *during* goto *do* restart_action

Looking at the generated plan

pnp1

you can see that the interrupt is incorretly added to the say action instead of the goto. Changing the rule to

*if* failed *during* say *do* restart_action

Produces the following error:

Generation of PNP 'greet'
Plan: goto_forward; say_hello
Applying execution rules for action say
    failed -> restart_action

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff792445b in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&) ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) bt
#0  0x00007ffff792445b in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&) ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x00007ffff7bb2187 in Node::getName (this=0x6093c0)
    at /home/cd32/pnp_ws/src/PetriNetPlans/PNPgen/include/PNPgen/pnpgenerator.h:74
#2  0x00007ffff7bac2b4 in PNP::addInterrupt (
    this=0x7fffffffc650, pi=0x6091a0, 
    condition="failed", po=0x609170)
    at /home/cd32/pnp_ws/src/PetriNetPlans/PNPgen/src/pnpgenerator.cpp:332
---Type <return> to continue, or q <return> to quit---
#3  0x00007ffff7bb04ab in PNPGenerator::applyExecutionRules (this=0x7fffffffc5b0)
    at /home/cd32/pnp_ws/src/PetriNetPlans/PNPgen/src/pnpgenerator.cpp:696
#4  0x00000000004040f0 in create_PNP_from_linear_plan (
    planfile="greet.plan", erfile="greet.er")
    at /home/cd32/pnp_ws/src/PetriNetPlans/PNPgen/src/pnpgen_linear.cpp:36
#5  0x0000000000404354 in main (argc=3, 
    argv=0x7fffffffc848)
    at /home/cd32/pnp_ws/src/PetriNetPlans/PNPgen/src/pnpgen_linear.cpp:63

The line numbers might not be the same as in the current version of the file because I made some minor changes but I believe that the error lies here: https://github.com/iocchi/PetriNetPlans/blob/master/PNPgen/src/pnpgenerator.cpp#L331 by calling next twice I guess that you compensate for the fact that there are additional connecting places and transitions due to the concurrent wait action and the required fork operator. If there is no wait action, these places are missing and, therefore, the rule is applied two places to the right of the place it should be applied to. If there are no additional places to the right, this results in above segfault. Hence, when trying to interrupt the goto action it applies it to the say action and when interrupting the say action it runs into undefined memory because the plan ends before it finds a place.

iocchi commented 8 years ago

This problem should also be solved now. Thanks for spotting it.

cdondrup commented 8 years ago

The plan is now correctly created. Given:

goto_forward; say_hello

and

*if* failed *during* goto *do* restart_action
*if* robot_dist_far *during* say *do* restart_plan

I get:

pnp2

Thank you!