News:

Simutrans Forum Archive
A complete record of the old Simutrans Forum.

[Scenario tutorial] Error in api script

Started by Yona-TYT, October 27, 2020, 09:05:28 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT



It happened when I clicked on the link that runs script to skip steps.
Script: https://drive.google.com/file/d/1RHxKneghf91gpSakL_sZwJyWCt5hOOUm/view?usp=sharingSavegame: https://drive.google.com/file/d/1RHxKneghf91gpSakL_sZwJyWCt5hOOUm/view?usp=sharing

(gdb) where
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff6767801 in __GI_abort () at abort.c:79
#2  0x00007ffff675739a in __assert_fail_base (
    fmt=0x7ffff68de7d8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
    assertion=assertion@entry=0x555555946a94 "0",
    file=file@entry=0x55555592e5a9 "boden/wege/weg.cc", line=line@entry=87,
    function=function@entry=0x55555592e760 <weg_t::alloc(waytype_t)::__PRETTY_FUNCTION__> "static weg_t* weg_t::alloc(waytype_t)") at assert.c:92
#3  0x00007ffff6757412 in __GI___assert_fail (
    assertion=assertion@entry=0x555555946a94 "0",
    file=file@entry=0x55555592e5a9 "boden/wege/weg.cc", line=line@entry=87,
    function=function@entry=0x55555592e760 <weg_t::alloc(waytype_t)::__PRETTY_FUNCTION__> "static weg_t* weg_t::alloc(waytype_t)") at assert.c:101
#4  0x000055555564e06c in weg_t::alloc (wt=wt@entry=ignore_wt)
    at boden/wege/weg.cc:87
#5  0x000055555589d30a in tool_build_way_t::get_desc (this=<optimized out>,
    timeline_year_month=<optimized out>, remember=<optimized out>)
    at simtool.cc:2236
#6  0x00005555558a3327 in tool_build_way_t::init (this=0x555571281840, player=
    0x55557525b880) at simtool.cc:2328
#7  0x00005555557acd64 in script_api::param<script_api::call_tool_work>::push (
    vm=vm@entry=0x555575249050, v=...) at script/api/api_command.cc:216
#8  0x00005555557ad2f1 in command_work (vm=0x555575249050)
---Type <return> to continue, or q <return> to quit---
    at script/api/api_command.cc:166
#9  0x0000555555905709 in SQVM::CallNative (this=this@entry=0x555575249050,
    nclosure=0x55557533e970, nargs=<optimized out>, newbase=<optimized out>,
    retval=..., suspend=@0x7fffffffa640: false)
    at squirrel/squirrel/sqvm.cc:1216
#10 0x00005555559066ca in SQVM::Execute (this=0x555575249050, closure=...,
    nargs=<optimized out>, stackbase=<optimized out>, outres=...,
    raiseerror=1, et=SQVM::ET_CALL, can_suspend=1)
    at squirrel/squirrel/sqvm.cc:780
#11 0x0000555555908112 in SQVM::Call (this=this@entry=0x555575249050,
    closure=..., nparams=nparams@entry=1, stackbase=stackbase@entry=2,
    outres=..., raiseerror=raiseerror@entry=1, can_suspend=1)
    at squirrel/squirrel/sqvm.cc:1585
#12 0x00005555558e8910 in sq_call (v=v@entry=0x555575249050, params=1,
    retval=1, raiseerror=raiseerror@entry=1) at squirrel/squirrel/sqapi.cc:1179
#13 0x00005555558dd054 in sq_call_restricted (v=v@entry=0x555575249050,
    params=<optimized out>, retval=<optimized out>,
    throw_if_no_ops=throw_if_no_ops@entry=0, ops=ops@entry=10000)
    at squirrel/sq_extensions.cc:56
#14 0x0000555555838141 in script_vm_t::intern_call_function (
    job=job@entry=0x555575249050, ct=ct@entry=script_vm_t::QUEUE,
    nparams=<optimized out>, nparams@entry=1, retvalue=<optimized out>,
    retvalue@entry=true) at script/script.cc:305
---Type <return> to continue, or q <return> to quit---where
#15 0x00005555558388b5 in script_vm_t::intern_finish_call (
    this=0x55557522ead0, job=0x555575249050, ct=ct@entry=script_vm_t::QUEUE,
    nparams=nparams@entry=1, retvalue=retvalue@entry=true)
    at script/script.cc:288
#16 0x00005555558389ba in script_vm_t::eval_string (this=<optimized out>,
    squirrel_string=<optimized out>) at script/script.cc:203
#17 0x00005555556629ba in scenario_t::eval_string (this=<optimized out>,
    squirrel_string=squirrel_string@entry=0x5555751f5157 "script_text()")
    at dataobj/scenario.cc:937
#18 0x0000555555734449 in scenario_info_t::action_triggered (
    this=0x555571de4090, comp=<optimized out>, v=...)
    at gui/scenario_info.cc:129
#19 0x00005555556b9d3f in gui_action_creator_t::call_listeners (
    this=0x555571de4578, v=...) at gui/components/gui_action_creator.h:32
#20 0x00005555556c1846 in gui_flowtext_t::action_triggered (
    this=<optimized out>, extra=...) at gui/components/gui_flowtext.cc:605
#21 0x00005555556b9d3f in gui_action_creator_t::call_listeners (
    this=this@entry=0x5555751b2610, v=...)
    at gui/components/gui_action_creator.h:32
#22 0x00005555556c27d9 in gui_flowtext_intern_t::infowin_event (
    this=0x5555751b25f0, ev=<optimized out>)
    at gui/components/gui_flowtext.cc:541
#23 0x00005555556caec0 in gui_scrollpane_t::infowin_event (
---Type <return> to continue, or q <return> to quit---where
    this=0x555571de4590, ev=<optimized out>)
    at gui/components/gui_scrollpane.cc:168
#24 0x00005555556cc4af in gui_tab_panel_t::infowin_event (this=0x555571de4108,
    ev=<optimized out>) at gui/components/gui_tab_panel.cc:149
#25 0x00005555556befe6 in gui_container_t::infowin_event (
    this=this@entry=0x555571de5830, ev=ev@entry=0x7fffffffaca0)
    at gui/components/gui_container.cc:201
#26 0x00005555556fb53b in gui_frame_t::infowin_event (this=<optimized out>,
    ev=<optimized out>) at gui/gui_frame.cc:132
#27 0x000055555575165a in check_pos_win (ev=ev@entry=0x7fffffffafc0)
    at gui/simwin.cc:1521
#28 0x000055555587f0ee in interaction_t::process_event (
    this=this@entry=0x5555596d5910, ev=...) at siminteraction.cc:362
#29 0x000055555587f61b in interaction_t::check_events (this=0x5555596d5910)
    at siminteraction.cc:435
#30 0x00005555558d9a58 in karte_t::interactive (
    this=this@entry=0x5555712451f0, quit_month=quit_month@entry=2147483647)
    at simworld.cc:7244
#31 0x0000555555887a2c in simu_main (argc=argc@entry=1,
    argv=argv@entry=0x7fffffffdf18) at simmain.cc:1512
#32 0x000055555590c254 in sysmain (argc=1, argv=0x7fffffffdf18)
    at sys/simsys.cc:1102
#33 0x00007ffff6748b97 in __libc_start_main (

Edit.
This occurs because the road name was wrong when calling:                    local t = command_x(tool_build_way)
                    local err = t.work(player_x(0), t_start, t_end, sc_way_name)

Dwachs

tool.work does not check for invalid input. Please use command_x::build_way (and other such functions) which do have error checking.

Still there should be some error checking to prevent this assertion from firing.
Parsley, sage, rosemary, and maggikraut.

Dwachs

added a check in r9349, this should not happen anymore
Parsley, sage, rosemary, and maggikraut.