News:

SimuTranslator
Make Simutrans speak your language.

function "is_work_allowed_here" gets stuck in infinite loop

Started by Yona-TYT, November 30, 2022, 07:10:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT


I think I mentioned this bug before, but now I've confirmed it.

Unfortunately it is not easy to reproduce and I only get it in the tutorial.

What happens is the following:
When I use the tunnel tool under specific conditions in the "is_work_allowed_here" function, for some reason in some cases the condition will fail causing an infinite loop "possibly in the tool" and this generates an infinite execution of "is_work_allowed_here".

Once it occurs there is no way to escape this, even if you reload the scenario's savegame, the infinite loop continues there.

It's strange isn't it? This has me baffled. :o

Dwachs

Then please send the savegame (and the scenario). If it is reproducible it can be fixed. hopefully.
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

The text label indicates the number of times "is_work_allowed_here" is executed.

Look at this video:



Quote from: Dwachs on November 30, 2022, 07:13:17 PMThen please send the savegame (and the scenario). If it is reproducible it can be fixed. hopefully.
This is the new tutorial scenario I'm working on for pak192.comic (this bug forces me to reveal it early hehehehe). ;D

scenario: tutorial-pak192.comic-test.zip

savegame: tutorial-33333test.sve

Dwachs

Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Quote from: Dwachs on December 03, 2022, 12:31:20 PMshould be fixed in r10825

Now I'm getting a crash on simutrans.  :o

Thread 1 "simutrans" received signal SIGSEGV, Segmentation fault.
0x0000555555a6e3bc in SQVM::Remove(long long) ()
(gdb) where
#0  0x0000555555a6e3bc in SQVM::Remove(long long) ()
#1  0x0000555555952c5f in script_vm_t::intern_prepare_call(SQVM*&, script_vm_t::call_type_t, char const*) ()
#2  0x00005555556a22d3 in scenario_t::is_work_allowed_here(player_t const*, unsigned short, short, koord3d) ()
#3  0x0000555555a2554b in karte_t::interactive(unsigned int) ()
#4  0x000055555598fffd in simu_main(int, char**) ()
#5  0x0000555555997445 in sysmain(int, char**) ()
#6  0x00007ffff7554290 in __libc_start_call_main (
    main=main@entry=0x55555563c490 <main>, argc=argc@entry=1,
    argv=argv@entry=0x7fffffffe818)
    at ../sysdeps/nptl/libc_start_call_main.h:58
#7  0x00007ffff755434a in __libc_start_main_impl (main=0x55555563c490 <main>,
    argc=1, argv=0x7fffffffe818, init=<optimized out>, fini=<optimized out>,
    rtld_fini=<optimized out>, stack_end=0x7fffffffe808)
    at ../csu/libc-start.c:381
#8  0x000055555563c55e in _start ()
(gdb)
Captura desde 2022-12-03 16-22-00.png

Dwachs

Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Quote from: Dwachs on December 03, 2022, 09:22:23 PMHow?
hahahaha translation error, I meant something like " simutrans it shock". ;D

Quote from: Yona-TYT on December 03, 2022, 08:24:57 PMNow I'm getting a crash on simutrans.  :o
The firefox translator tells me "Now I'm ruining Simutrans". lol

Dwachs

The problem is the gui.add_message call from is_work_allowed. The script gets suspended, which should not happen, and causes a squirrel stack overflow.

Edit: there is a bug in the script.cc code. Please do not call gui.add_message (or any tool/command) from is_work_allowed. This will cause the crash, when dragging the tunnel tool into forbidden regions. Not sure how to properly fix this.
Parsley, sage, rosemary, and maggikraut.

Dwachs

The crash should be fixed in r10829. Next step would be to enable gui.add_message for such function calls.
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Quote from: Dwachs on December 03, 2022, 10:13:12 PMThe problem is the gui.add_message call from is_work_allowed. The script gets suspended, which should not happen, and causes a squirrel stack overflow.
Edit: there is a bug in the script.cc code. Please do not call gui.add_message (or any tool/command) from is_work_allowed. This will cause the crash, when dragging the tunnel tool into forbidden regions. Not sure how to properly fix this.
I didn't know what to call there that was causing so much trouble. :P

Quote from: Dwachs on December 04, 2022, 09:58:19 AMThe crash should be fixed in r10829. Next step would be to enable gui.add_message for such function calls.
The truth is that even simutrans fails if I call gui there . :o

Dwachs

Can you be more specific? Do you still get that crash with r10829?
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Quote from: Dwachs on December 05, 2022, 06:56:09 AMCan you be more specific? Do you still get that crash with r10829?
Yes, the r10829 is failing, use the scenario and the savegame that I shared in the other post.

Dwachs

I do not get any crashes. What should I do to get the tutorial to crash simutrans?
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Quote from: Dwachs on December 05, 2022, 05:56:52 PMI do not get any crashes. What should I do to get the tutorial to crash simutrans?
Wait a minute, r10829 hasn't made it to github yet...  I did the tests with , r10828

Yona-TYT

Look at this video: https://youtu.be/mQ4DboU5Pjk

The script code is:
function is_work_allowed_here(pl, tool_id, pos)
{
gui.add_message("hello")
return null
}



Dwachs

This should be fixed with r10829, which is at github since two days ago. With with revision did you record the video?
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Quote from: Dwachs on December 06, 2022, 05:19:01 PMThis should be fixed with r10829, which is at github since two days ago. With with revision did you record the video?

r10828
Screenshot 2022-12-06 at 13-58-33 simutrans_simutrans.png

Dwachs

Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Quote from: Dwachs on December 06, 2022, 09:03:33 PMDo not know why, but I can download r10829 on github :/
It's because you are using the old repo "https://github.com/aburch/" And I use "https://github.com/simutrans/"

EDIT.

Apparently github played a trick on me with revisions. :o

I confirm that r10829 no longer hangs/breaks simutrans.

Although my custom is to use messages in gui for debugging and testing, so at the moment I'm limited in that aspect. :-[



Dwachs

Enabling these messages again is the next thing on my todo-list.
Parsley, sage, rosemary, and maggikraut.


Dwachs

Parsley, sage, rosemary, and maggikraut.

Yona-TYT


Dwachs

Please do not call any commands in is_allwed_here. This is a bug of the script not of simutrans.
Parsley, sage, rosemary, and maggikraut.