klipse icon indicating copy to clipboard operation
klipse copied to clipboard

klipse freezes far too easily

Open rdebath opened this issue 7 years ago • 12 comments

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.

rdebath avatar Dec 19 '16 09:12 rdebath

Can you give a detailed example? What language are you editing?

Maybe you could share an animated gif?

On Mon, Dec 19, 2016, 11:24 rdebath [email protected] wrote:

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.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/viebel/klipse/issues/162, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6VPpbeOYh1xva_OutZhejpYgxP4Sscks5rJk1MgaJpZM4LQhSv .

viebel avatar Dec 19 '16 09:12 viebel

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.

rdebath avatar Dec 19 '16 09:12 rdebath

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!!!

viebel avatar Dec 19 '16 09:12 viebel

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.

rdebath avatar Dec 19 '16 12:12 rdebath

Indeed it can be done with web worker. I have forked a gist that does eval in a web worker https://gist.github.com/viebel/707cc19e288aa9f40510333187f06f53

But I didn't integrated into klipse - yet Again, a PR is welcome :)

On Mon, 19 Dec 2016 at 14:00 rdebath [email protected] wrote:

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.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/viebel/klipse/issues/162#issuecomment-267947960, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6VPuRzo2xkTbXMgRgH21LqRZOU_V6mks5rJnHkgaJpZM4LQhSv .

viebel avatar Dec 19 '16 12:12 viebel

BTW, all the brainfuck programs that you mentioned are the same.

On Mon, 19 Dec 2016 at 14:40 Yehonathan Sharvit [email protected] wrote:

Indeed it can be done with web worker. I have forked a gist that does eval in a web worker https://gist.github.com/viebel/707cc19e288aa9f40510333187f06f53

But I didn't integrated into klipse - yet Again, a PR is welcome :)

On Mon, 19 Dec 2016 at 14:00 rdebath [email protected] wrote:

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.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/viebel/klipse/issues/162#issuecomment-267947960, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6VPuRzo2xkTbXMgRgH21LqRZOU_V6mks5rJnHkgaJpZM4LQhSv .

viebel avatar Dec 19 '16 12:12 viebel

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...

rdebath avatar Dec 19 '16 13:12 rdebath

Thx for the clarifications.

On Mon, 19 Dec 2016 at 15:38 rdebath [email protected] wrote:

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...

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/viebel/klipse/issues/162#issuecomment-267965644, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6VPhJtKaoZyYz2clgwn6_GrSIJf7edks5rJoi4gaJpZM4LQhSv .

viebel avatar Dec 19 '16 14:12 viebel

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.

rachitnigam avatar May 10 '18 16:05 rachitnigam

@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...?

viebel avatar Jun 10 '18 12:06 viebel

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

workshub[bot] avatar Jun 02 '20 15:06 workshub[bot]

@darknightm started working on this issue via WorksHub.

workshub[bot] avatar Aug 14 '20 17:08 workshub[bot]