locked
A new exception RRS feed

  • General discussion

  • Hello Small Basic Community!

    I found a new exception in Small Basic and it is not included in this article (https://social.technet.microsoft.com/wiki/contents/articles/29200.small-basic-errors.aspx). I found this exception while making a YouTube video and this is the code which caused the error. The name of the exception is 'StackOverFlowException'

    This is the code

    num = 1
    num2 = 6
    main()
    Sub main
      num2 = num * (num + 1)
      TextWindow.WriteLine(num2)
      main()
    EndSub

    Output : 

    

    I am sorry if any inconvenience is caused.

    Thanks.


    Roshan - 8th Grade Student (Age 13) - Learning Learning Python, Machine Learning and C#


    Wednesday, January 2, 2019 4:27 PM

All replies

  • This is a call stack overflow due to the infinite recursion.  The call stack records a stack of what called the current subroutine, so when the subroutine ends it knows where to 'jump' back to.

    There is a hard limit on the size of the call stack for small basic and all other softawre languages - so this in't a compiler bug, rather a coding bug.

    The following shows the limit is 2759 on my PC

    count = 0
    main()
    Sub main
      count = count+1
      TextWindow.WriteLine(count)
      main()
    EndSub

    Wednesday, January 2, 2019 6:13 PM
  • My conputer reaches 5150 + or - 10

    Jan [ WhTurner ] The Netherlands


    Wednesday, January 2, 2019 6:35 PM
    Answerer
  • There are even more limits.

    The subroutine limit is on my PC 2761.

    It's 1763 with Push to an extra stack.

    It's 1670 with Push and Pop.

    It's 1134 with  Program.Delay() !? 

    count = 0
    main()
    Sub main
      count = count+1
      Stack.PushValue("AUX",count)
      TextWindow.WriteLine(count)
      Program.Delay(1)
      x=Stack.PopValue("AUX")
      main()
    EndSub

     



    Wednesday, January 2, 2019 10:56 PM
  • Thank you  all soo much for your replies. I'm new to Small Basic soo I didn''t know about this exception.

    Roshan - 8th Grade Student (Age 13) - Learning Learning Python, Machine Learning and C#

    Thursday, January 3, 2019 12:13 PM

  • Some nice descriptions of program stack and heap used internally in SB and all software programs here.  A program stack is not the Stack object in SB.
    Thursday, January 3, 2019 10:16 PM