Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

klipse freezes far too easily #162

Open
rdebath opened this issue Dec 19, 2016 · 12 comments
Open

klipse freezes far too easily #162

rdebath opened this issue Dec 19, 2016 · 12 comments

Comments

@rdebath
Copy link

rdebath commented Dec 19, 2016

When you're editing code it's good practice to keep it syntactically correct as much as possible.
Certain editors make it difficult; for example "Intellisense" is really dumb about this grabbing various keys and generally behaving like a headless chicken.

OTOH, various editors try to be helpful, inserting the closing structure automatically when you enter the start of a loop or condition. This doesn't always work very well either.

Currently, klipse is probably one of the least helpful I've come across. You basically have to force a syntax error at the top of the code to keep it from crashing and if you (for example) decrement the wrong variable within a loop you lose what you've typed.

The solution is simple in concept; the code should only run until the next keypress ... no more.

@viebel
Copy link
Owner

viebel commented Dec 19, 2016 via email

@rdebath
Copy link
Author

rdebath commented Dec 19, 2016

The one I tried was ruby, you're typing this in.

$i = 0
$num = 5

while $i < $num  do
   puts("Inside the loop i = #$i" )
   $i +=1
end

First type this:

$i = 0
$num = 5

Then add the loop;

while $i < $num  do
end

Lastly fill in the loop ...

while $i < $num  do
   puts("Inside the loop i = #$i" )
   $i +=1
end

You won't get to lastly.

@viebel
Copy link
Owner

viebel commented Dec 19, 2016

I see.

The browser is stuck in an infinite loop. I've solved this issue in clojure and brainfuck by detecting infinite loops and stopping the execution.

But it's not yet implemented in ruby.

A possible workaround is to set the data-eval-idle-msec attribute to a bigger value - see https://github.com/viebel/klipse#snippet-level-configuration.
Maybe, eventually as you suggest I will have a button.

A PR is more than welcome!!!

@rdebath
Copy link
Author

rdebath commented Dec 19, 2016

detecting infinite loops

Heh, I think Dr. Turing might have something to say about that.
But I expect you're just limiting the number of instructions that can be run; the problem with that is that sometimes I'm a lot more patient than others.
Eg: This shouldn't be too long...

++  [>++++<-]>[>+++<-]< +[>>>[>>]<[[->>+<<]>>-[<<]]>+<<[-<<]<]

OTOH: This is a lot longer, but I might want to wait for it once in a while.

+++ [>++++<-]>[>+++<-]< +[>>>[>>]<[[->>+<<]>>-[<<]]>+<<[-<<]<]

But I'm not going to wait for this one.

++++[>++++<-]>[>+++<-]< +[>>>[>>]<[[->>+<<]>>-[<<]]>+<<[-<<]<]

Actually, I was thinking more of threading or background processes. Something that can be started on a different core and 'killed' if the user doesn't wait for it. A bit like the spelling checker in a web browser...
I understand something called "Web Workers" can do that.

@viebel
Copy link
Owner

viebel commented Dec 19, 2016 via email

@viebel
Copy link
Owner

viebel commented Dec 19, 2016 via email

@rdebath
Copy link
Author

rdebath commented Dec 19, 2016

Um: They begin with two, three or four pluses.
That means the first one runs about 167772160 BF instructions, the second one runs about 687194767360 instructions and the third one runs around 2814749767106560 instructions.

That third one will take several days to complete on the fastest BF 'interpreter' around.
If you add another plus it'll probably take about 100 years...

@viebel
Copy link
Owner

viebel commented Dec 19, 2016 via email

@rachitnigam
Copy link

Hey, we have something that will help with the problem: http://www.stopify.org/
We built a source to source compiler for JS that can instrument programs to prevent them from freezing the browser. You can check out our demo to see this in action (link above).

If you'd be interested in getting Klipse to use this, let me know. I'd be happy to help. The API is straightforward and does not require you to modify your compiler.

@viebel
Copy link
Owner

viebel commented Jun 10, 2018

@rachitnigam I'd be happy to use stopify inside Klipse.

  1. What compiler option should I use?
  2. Is there a way to prevent from the code to do any malicious actions like stealing cookies etc...?

@workshub
Copy link

workshub bot commented Jun 2, 2020

If you successfully complete this Issue via WorskHub there's a $250 reward available.
Start work via WorksHub Issue Details page.

@workshub
Copy link

workshub bot commented Aug 14, 2020

@darknightm started working on this issue via WorksHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants