1. 13

Sneklang is an experimental subset of python for safe evaluation. It’s a project I’ve been working on for a while now and decided to put my server where my mouth is. Please break it if you can!


  2. 6

    I think the following code crashed the server:

    def deep_but_shared(n):
    	result = []
    	while n > 0:
    		result = [result, result]
    		n = n - 1
    	return result
    1. 5


      Congrats! If this is was yours, it did cause an actual error. It causes memory to massively jump between checks.

      1. 1

        Yep! That was me. :)

      2. 2

        Thank you! the result was a bit too long for the templates to handle reasonably. Have to truncate results now…

      3. 2

        Good idea to get people to break it. I heard about Sneklang a little while ago and thought it sounded quite useful.

        Are there any APIs to execute Sneklang from other languages yet? Like if I have a C# program that allows users to enter input in Sneklang, then executes it and uses the results within the program.

        1. 1

          I think I’ll make a CLI for it at some point, maybe let it read to stdin and print to stdout…

        2. 1

          I think I killed it! Similar to exists-forall’s example:

          b = []
          i = 50
          while i > 0:
          	b = [b, [b]]
          	i = i - 1
          1. 1

            So this is interesting, creating b is ok and within the bounds, but converting it to a string is where the problem lays.

            1. 1

              That was fun to fix, ok now the size of the evaluated expression is also included in the scope size check. https://sneklang.functup.com/v1/runs/9336c1835a765658589bf51c283e80744328d484

              ScopeTooLarge(‘Scope has used too much memory: 25100 > 20000.0 at line: 4, column:5’)

            2. 1

              Also, just a heads-up–when I install sneklang package with pip, it breaks trying to import forge (which, for some reason, cannot be installed).

              1. 1

                Ok fixed this, thank you!