itemisCREATE / examples

YAKINDU Statechart Tools examples
21 stars 25 forks source link

coffee_machine_pro segfaults #68

Closed BeckmaR closed 5 years ago

BeckmaR commented 7 years ago

System: Ubuntu 64 Bit, gcc 5.4.0

!!!Hello Coffee!!!
general commands are:
(o) toggle on/off
(t) toggle state trace
(q) quit
-> [On]
o
[On] ->
-> [On.Welcome]
** Welcome to YAKINDU Coffee Maker **
-> [On.HeatingUp]
[On.HeatingUp] ->
* heating-> [On.WaitForChoice]
...............[On.WaitForChoice] ->

* choose:
(1) coffee
(2) espresso
(3) cappucino
(4) latte macchiato
(5) milk
-> [On.SaveEnergy]
2
[On.SaveEnergy] ->
Preparing espresso-> [On.ProcessRecipe.MakeMilk]
-> [On.ProcessRecipe.MakeCoffee.MillingBeans]
-> [On.ProcessRecipe.MakeCoffee.BrewCoffee]
....................[On.ProcessRecipe.MakeCoffee.BrewCoffee] ->
Speicherzugriffsfehler (Speicherabzug geschrieben)
BeckmaR commented 7 years ago
(gdb) backtrace
#0  0x00007ffff783fcc0 in _IO_vfprintf_internal (s=0x7ffff67eb6e0, 
    format=<optimized out>, ap=0x7ffff67edd98) at vfprintf.c:1632
#1  0x00007ffff7840ef1 in buffered_vfprintf (
    s=0x7ffff7bb5540 <_IO_2_1_stderr_>, format=<optimized out>, 
    args=<optimized out>) at vfprintf.c:2320
#2  0x00007ffff783e32d in _IO_vfprintf_internal (
    s=0x7ffff7bb5540 <_IO_2_1_stderr_>, format=0x4034bf "-> [%s]\n", 
    ap=ap@entry=0x7ffff67edd98) at vfprintf.c:1293
#3  0x00007ffff78467f7 in __fprintf (stream=<optimized out>, 
    format=<optimized out>) at fprintf.c:32
#4  0x0000000000402ece in coffeeMachine_stateEntered (
    handle=0x605200 <coffee_state_machine>, 
    state=CoffeeMachine_main_On_r_Process_Recipe_r_Make_Coffee_r_Brew_Coffee)
    at ../src/cm_trace.c:35
#5  0x0000000000401e1a in coffeeMachine_enseq_main_On_r_Process_Recipe_r_Make_Coffee_r_Brew_Coffee_default (handle=0x605200 <coffee_state_machine>)
    at ../src/CoffeeMachine.c:802
#6  0x0000000000401796 in coffeeMachine_effect_main_On_r_Process_Recipe_r_Make_Coffee_r_Milling_Beans_tr0 (handle=0x605200 <coffee_state_machine>)
    at ../src/CoffeeMachine.c:528
#7  0x000000000040298e in coffeeMachine_react_main_On_r_Process_Recipe_r_Make_Coffee_r_Milling_Beans (handle=0x605200 <coffee_state_machine>)
    at ../src/CoffeeMachine.c:1328
#8  0x00000000004010f6 in coffeeMachine_runCycle (
    handle=0x605200 <coffee_state_machine>) at ../src/CoffeeMachine.c:240
#9  0x0000000000402d8c in run_cycle (handle=0x605200 <coffee_state_machine>)
    at ../src/cm_main.c:47
#10 0x0000000000400a52 in sc_cycle_runner_thread (arg=0x605240 <cycle_runner>)
    at ../src/scutil/sc_cycle_runner.c:25
#11 0x00007ffff7bc16ba in start_thread (arg=0x7ffff67ee700)
    at pthread_create.c:333
#12 0x00007ffff78f782d in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
BeckmaR commented 7 years ago

The solution is simply the changed state enum (see ticket Yakindu/statecharts#1318). The coffee machine tracing code depends on the fact that the last_state was actually the last state of the enum, but now it's the first, incrementing all state numbers by 1. The solution is to add a "null_state" to the char* array of state names in the tracing code.

andreasmuelder commented 6 years ago

@BeckmaR so this is fixed now ?

rherrmannr commented 5 years ago

@BeckmaR is this fixed?