xy crashes when using SUB

Things you’d like to miss in the future...
Post Reply
CodeLobster

xy crashes when using SUB

Post by CodeLobster »

the following code has the sole purpose of demonstrating what happens when instead of WHILE loops one uses smartness inside SUB

as everythings ok with values <= 400 theres no real reason why xy should crash at the 401th execution of a working SUB statement so this falls into the bug category. edit: those values are true for v 9.90.1025. see my next post

Code: Select all

  global $pos, $cnt, $off, $len;
 $len = input("Enter The Line Youd Like to Jump To<crlf>suggested value is the maximum allowed", "MORE THAN SUGGESTED WILL CRASH XY - depending on the version used. Suggested refers to 9.90.1101" , "386");
 $off = 1;
 $cnt = 1;
 $pos = get("focusedpos");

  setting "allowrecursion", 1;
  sub (get("countselected") >= 1) ? (($cnt <= $len) ? "_sub1" : "_ok") : "_ok";
  setting "allowrecursion", r;

"_sub1"
  global $off, $len, $cnt;
 incr $cnt, $cnt;
 sub ($cnt <= $len) ? "_off" : "_done";
 sub (get("countselected") == 1) ? (($cnt <= $len) ? "_sub1" : "_ok") : "_ok";

"_off"
  global $off, $cnt;
 sel "+".$off;
 copytext "count: $cnt"; //just paste the value to clipboard after a crash and youll obtain the safe threshold to work with

"_done"
 status "task done";

"_ok"
  global $cnt, $pos;
 $last = $cnt - 1;
 status "item $last, started at: $pos";
Last edited by CodeLobster on 19 Jun 2011 19:40, edited 2 times in total.

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

Re: xy crashes when using SUB

Post by admin »

Cannot reproduce.

CodeLobster

Re: xy crashes when using SUB

Post by CodeLobster »

with the help of a frind and a coworker i got this which demonstrates that the problem is consistent and on a regular basis SUB statements are prone to crash sooner version after version.

some of my codes i can convert to a non-sub based version (WHILE loops and such) but they are losing smartness

thank you admin for trying and id like to ask other forum users to please try the code and report back with results

i will edit the code so it can match our fridays experiment that copies the latest safe value to the clipboard and runs faster, much faster in some cases

Code: Select all

user 1, S.J.
9.50: win7, x86, crashes at item 448 (max safe value is 447) and runs slowly due to "status: $cnt" on sub "_off", changing it to copytext "count: $cnt"; made an impressive difference speeding up the tests just like providing a quicker way to know what threshold breaks the script.
9.70: win7, x86, crashes at item 431 (max safe value is 430), incredibly faster than 9.50.
9.90.1001: win7, x86, crashes at item 403 (max safe value is 402)

user 2, T.P.
9.80: win7, x64, crashes at item 430 (max safe value is 429), a bit slower than 9.70
9.80.0131: win7, x64, crashes at item 427 (max safe value is 426), a bit faster than 9.80
9.90.0401: Vaio NB + Atom/Vista, crashes at item 408 (max safe value is 407)

user 3, me
9.90.1025: winXP sp1, x86, crashes at item 401 (max safe value is 400)
9.90.1101: win7, x86, crashes at item 387 (max safe value is 386)

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

Re: xy crashes when using SUB

Post by admin »

This heavy recursion leads to a stack overflow which is so evil that it cannot be trapped in a controlled way. The exact point when a stack overflow happens depends on the system (in ways unknown to me).

In other words, rewrite your script so that it does not build on recursion.

CodeLobster

Re: xy crashes when using SUB

Post by CodeLobster »

admin wrote:This heavy recursion leads to a stack overflow which is so evil that it cannot be trapped in a controlled way. The exact point when a stack overflow happens depends on the system (in ways unknown to me).

In other words, rewrite your script so that it does not build on recursion.
...beware the stack overflow... and it looks so innocent at the stepping window!

thanks anyway.

Post Reply