XY crashes on endless script

Things you’d like to miss in the future...
Forum rules
:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:

:info: Please include the following information:
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".

:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:
Post Reply
fishgod
Posts: 231
Joined: 03 Feb 2008 00:40
Location: Sankt Augustin (near Bonn), Germany

XY crashes on endless script

Post by fishgod »

XY-Version: 6.80.0061

Just for fun, i've wrote this simple script (where the script itself is located in <xypath>/scripts/test.xys):

Code: Select all

Foobar : foo::load scripts/test.xys, foo
-
Cancel
You can either load it with the paramter foo or click on Foobar to start the endless loop.
The result of this little experiment is that XY will crash and exits after about 1 second without any error-message (maybe because i've told windows not to generate a bug-report and such send-data-to-microsoft-suff)

Maybe you say, don't write such stupid scripts, but maybe there is a solution to test if a script walk in circles. I know that this would be hard because you have to check all the transitions between each script-call, but maybe you can simply test the runtime or the amount of commands processed in one go.
In case that it is not possible to catch this user-fault in an appropriate way, an advisement to the useres should be posted in the wiki.

In my further tests i've modified the script above to ensure how many times this script runs before XY crashes:

Code: Select all

Foobar : foo::goto E:\TEMP\foo\::#1401::load scripts/test.xys, foo
-
Cancel
(#1401 is a command to create a new file)

The Result of this experiment is a folder with 1155 files in it :lol:...
(on a second run, i've got exactly the same amount of files)
Maybe you simply restrict the amount of commands executeded in one go to 1000 or something to prevent XY crashing.


This endless loop is also possible without any external script-file, simply by creating an UDC ::#1408 and #1408 is the ID of the Script itself.
Extending this in the same way as above resolves in 671 files (= script circles), second run->same result.

admin
Site Admin
Posts: 66431
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: XY crashes on endless script

Post by admin »

fishgod wrote:The Result of this experiment is a folder with 1155 files in it :lol:...
I like this dadaistic approach to file management! Maybe 1155 is some new universal constant, the mysterious recursion limit.

So where's the problem? Scripting means power, and power means responsibility (wasn't that a quote from Spiderman?). It's not my business to protect you from yourself. :)

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: XY crashes on endless script

Post by jacky »

admin wrote:So where's the problem? Scripting means power, and power means responsibility (wasn't that a quote from Spiderman?). It's not my business to protect you from yourself. :)
"With great power comes great responsibility". Crap, I feel like a geek now... :P
Proud XYplorer Fanatic

admin
Site Admin
Posts: 66431
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: XY crashes on endless script

Post by admin »

fishgod wrote:XY-Version: 6.80.0061

Just for fun, i've wrote this simple script (where the script itself is located in <xypath>/scripts/test.xys):

Code: Select all

Foobar : foo::load scripts/test.xys, foo
-
Cancel
I added a recursion checker that handles this nasty stuff quite well. :)

fishgod
Posts: 231
Joined: 03 Feb 2008 00:40
Location: Sankt Augustin (near Bonn), Germany

Post by fishgod »

I wondered how fast you were able to create that recursion-checker, so I attemted to test it in my way.
The script written in your posting now creates exactly 4 files before it will be terminated. Then I thougth, what if I create another command and let the script jump from one to another and back. I'am very happy that the recursion checker also works pretty nice here, but the amount of created files is still the same where I expected that the amount would double, but ok.

So here comes my first question, what if I want to create more than 4 files, e.g. 8 files? (without real recursion) see the script below, its pretty simple at all:

Code: Select all

Foo : foo::goto E:\TEMP\foo\::#1401::load scripts/test.xys, bar
Bar : bar::goto E:\TEMP\foo\::#1401::load scripts/test.xys, bar2
Bar : bar2::goto E:\TEMP\foo\::#1401::load scripts/test.xys, bar3
Bar : bar3::goto E:\TEMP\foo\::#1401::load scripts/test.xys, bar4
Bar : bar4::goto E:\TEMP\foo\::#1401::load scripts/test.xys, bar5
Bar : bar5::goto E:\TEMP\foo\::#1401::load scripts/test.xys, bar6
Bar : bar6::goto E:\TEMP\foo\::#1401::load scripts/test.xys, bar7
Bar : bar7::goto E:\TEMP\foo\::#1401
-
Abbrechen
(#1401 creates a new file, same as in my other scripts...) yeah I could repeat only the #1401 eight times to create eigth files but thats to simple :P

That script doesn't run in circles, it should create exact 8 files, not more not less, and it will end, because it doesn't start itself, scripts are only stored in the same file.... but it don't work!
It creates 4 files and after that it will be terminated by the recursion-checker.

Any other try to start one script by another will end after the fourth start.
Operating System: Win10 x64 / Win11 x64 / almost allways newest XY-beta
totally XYscripting-addicted

admin
Site Admin
Posts: 66431
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post by admin »

fishgod wrote:I wondered how fast you were able to create that recursion-checker, so I attemted to test it in my way.
I knew you would try to break it and succeed... :) ... okay, I'll come up with something better next time...

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

fishgod wrote:So here comes my first question, what if I want to create more than 4 files, e.g. 8 files? (without real recursion)
On that note, with nothing to do with recursion, I would like that the command "new" could receive an extra optional parameter : number of items to create.
Either with a Batch Rename pattern as name, or keep using the number suffix but select all items after creation, so I can do a "rename" afterwards :)
Proud XYplorer Fanatic

fishgod
Posts: 231
Joined: 03 Feb 2008 00:40
Location: Sankt Augustin (near Bonn), Germany

Post by fishgod »

@jacky
Good idea, I don't know why to create a couple of identical files in one go, i've only used it here to test the scripting-power, but maybe others will need this feature


@admin
I know how hard it would be to create a real recursion-checker, so don't set your priority to high on this feature.
But everybody should be familiar with the ability to build recursions...
The ability to load one script by another is very powerfull, and offers you to build single modules. So if there are more comands in the future the limit of 4 script-calling scripts will be fast arrived
Maybe you simply increase the number to 100 (for now) and nobody would ever reach this limit by creating scripts with more sense then the test-scripts done by me.
Operating System: Win10 x64 / Win11 x64 / almost allways newest XY-beta
totally XYscripting-addicted

admin
Site Admin
Posts: 66431
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post by admin »

fishgod wrote:I know how hard it would be to create a real recursion-checker, so don't set your priority to high on this feature.
But everybody should be familiar with the ability to build recursions...
The ability to load one script by another is very powerfull, and offers you to build single modules. So if there are more comands in the future the limit of 4 script-calling scripts will be fast arrived...
So you think my recursion-checker is that primitive? :P No, it's perfect in theory, I just made a stupid little mistake in the implementation. It's already fixed, you'll get it tomorrow.

fishgod
Posts: 231
Joined: 03 Feb 2008 00:40
Location: Sankt Augustin (near Bonn), Germany

RecursionChecker again

Post by fishgod »

:D

Simply start ::write and try to run ::write from the XYplorer: Enter Script-Box, and XY say's you that
The current script appears to be recursive!
It is terminated now.


should't it be possible to do such things?

Maybe it is easier to implement a stacklimit insteat of the recursionchecker because it seems to be hard to implement it perfectly.
(if you write an endless program in C in will hang, but it shouldn't crash the system => so I think an endless script should maybe work, but in case it's on the way to crash XY it should be terminated.)
Operating System: Win10 x64 / Win11 x64 / almost allways newest XY-beta
totally XYscripting-addicted

admin
Site Admin
Posts: 66431
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: RecursionChecker again

Post by admin »

fishgod wrote::D

Simply start ::write and try to run ::write from the XYplorer: Enter Script-Box, and XY say's you that
The current script appears to be recursive!
It is terminated now.


should't it be possible to do such things?

Maybe it is easier to implement a stacklimit insteat of the recursionchecker because it seems to be hard to implement it perfectly.
(if you write an endless program in C in will hang, but it shouldn't crash the system => so I think an endless script should maybe work, but in case it's on the way to crash XY it should be terminated.)
I think write (now "try"!) is a special case. I can handle this. If you don't find any other problems I'll continue to be cntent with my recursionchecker. However, I will change it into a Yes/No prompt, so you can continue if you want to.

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: RecursionChecker again

Post by jacky »

admin wrote:I think write (now "try"!) is a special case. I can handle this. If you don't find any other problems I'll continue to be cntent with my recursionchecker. However, I will change it into a Yes/No prompt, so you can continue if you want to.
The Yes/No bit is a nice idea, yes.

I have a request about your recursionchecker though : could it be "reinitialized" when a menu is showed ? Take this for instance, assuming this file is called "hello.xys" :

Code: Select all

"Hello World" msg "Hello World"; load "hello";
-
"Cancel"
I'd like to be able to have it to say "Hello World" for as long as I want ! :) And since a menu is loaded, there obviously can't be no infinite loop (I mean, unless I decide to keep it running, of course, but that should be my problem... ;))
Proud XYplorer Fanatic

fishgod
Posts: 231
Joined: 03 Feb 2008 00:40
Location: Sankt Augustin (near Bonn), Germany

Post by fishgod »

both ideas are good, and yes now its called try, but I tested it on the old .0080-version...
Operating System: Win10 x64 / Win11 x64 / almost allways newest XY-beta
totally XYscripting-addicted

Post Reply