Discussion:
[dart-misc] bad behaving dart script on ubuntu
Daniel Davidson
2015-08-23 13:55:35 UTC
Permalink
I'm playing with petitparser, which is pretty cool and fun. I'm just
getting into it and was caught off guard when the following simple dart
script took over my machine:


import 'package:petitparser/petitparser.dart';
import 'package:petitparser/debug.dart';

main() {
showIt(p, s, [tag = '']) {
var result = p.parse(s);
print('''($tag): $result ${result.message}, ${result.position} in:
$s
123456789123456789
''');
}

final id = letter() & word().star();
final oops = id & char('(') & char(')').not().star() & char(')');

showIt(oops, 'foo(a)', 'as expected');
}


I'm running ubuntu and started this from emacs and I had to do a hard
reboot because I could not stop it or break into it. Suggestions for better
ways (magic keystrokes in ubuntu, etc) appreciated.

Because my questions cover several aspects - petitparser, dart, and ubuntu,
I thought I'd try this news group before SO.

First, on the petitparser the following original did not parse like I
expected it to:


final f2 = id & char('(') & any().star() & char(')');
showIt(f2, 'foo(a)', 'as expected');

I opened this question on it
<http://stackoverflow.com/questions/32166750/why-does-any-not-backtrack-in-this-example>.
I thought I'd figured out why the original didn't work and went to remedy
it with the *oops* line above. As I mentioned that did not work out well.
I'm pretty sure the problem with the *oops* line is that it causes an
infinite loop. I'm not sure whether that is expected behavior for
*petitparser* or not.


So, on the dart side of things, in general, under what circumstances can a
dart process bring a machine to a crawl like this?


As a test case I created a simple infinite loop in a dart script and when
run the laptop fan when on, but I was able to move the mouse, select other
apps, and kill the offender. My guess is the reason I could not do that for
the parser script is it's infinite loop was more complex and using
resources without releasing them?


On the unix side, is there an issue with my setup or will the same pretty
much happen on any platform?


Thanks,

Dan
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Lukas Renggli
2015-08-24 08:14:22 UTC
Permalink
Hi Dan,

I hope that my response on SO answered your question regarding PetitParser?

The parser char(')').not().star() loops infinitely. This is expected,
because not() is a predicate that does not consume its input. Check the
class documentation on this function and compare it with the comment on
neg(), which is likely what you wanted.

Cheers,
Lukas
Post by Daniel Davidson
I'm playing with petitparser, which is pretty cool and fun. I'm just
getting into it and was caught off guard when the following simple dart
import 'package:petitparser/petitparser.dart';
import 'package:petitparser/debug.dart';
main() {
showIt(p, s, [tag = '']) {
var result = p.parse(s);
$s
123456789123456789
''');
}
final id = letter() & word().star();
final oops = id & char('(') & char(')').not().star() & char(')');
showIt(oops, 'foo(a)', 'as expected');
}
I'm running ubuntu and started this from emacs and I had to do a hard
reboot because I could not stop it or break into it. Suggestions for better
ways (magic keystrokes in ubuntu, etc) appreciated.
Because my questions cover several aspects - petitparser, dart, and
ubuntu, I thought I'd try this news group before SO.
First, on the petitparser the following original did not parse like I
final f2 = id & char('(') & any().star() & char(')');
showIt(f2, 'foo(a)', 'as expected');
I opened this question on it
<http://stackoverflow.com/questions/32166750/why-does-any-not-backtrack-in-this-example>.
I thought I'd figured out why the original didn't work and went to remedy
it with the *oops* line above. As I mentioned that did not work out well.
I'm pretty sure the problem with the *oops* line is that it causes an
infinite loop. I'm not sure whether that is expected behavior for
*petitparser* or not.
So, on the dart side of things, in general, under what circumstances can a
dart process bring a machine to a crawl like this?
As a test case I created a simple infinite loop in a dart script and when
run the laptop fan when on, but I was able to move the mouse, select other
apps, and kill the offender. My guess is the reason I could not do that for
the parser script is it's infinite loop was more complex and using
resources without releasing them?
On the unix side, is there an issue with my setup or will the same pretty
much happen on any platform?
Thanks,
Dan
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Daniel Davidson
2015-08-24 10:58:40 UTC
Permalink
Post by Lukas Renggli
Hi Dan,
I hope that my response on SO answered your question regarding PetitParser?
Yes, thanks. Now it makes sense.
The parser char(')').not().star() loops infinitely. This is expected,
because not() is a predicate that does not consume its input. Check the
class documentation on this function and compare it with the comment on
neg(), which is likely what you wanted.
I see - thanks. I want to do more with this library and have not had
exposure to parser expression grammars. Can you recommend any books
(preferably not dry text books)?
Post by Lukas Renggli
Cheers,
Lukas
Post by Daniel Davidson
I'm playing with petitparser, which is pretty cool and fun. I'm just
getting into it and was caught off guard when the following simple dart
import 'package:petitparser/petitparser.dart';
import 'package:petitparser/debug.dart';
main() {
showIt(p, s, [tag = '']) {
var result = p.parse(s);
$s
123456789123456789
''');
}
final id = letter() & word().star();
final oops = id & char('(') & char(')').not().star() & char(')');
showIt(oops, 'foo(a)', 'as expected');
}
I'm running ubuntu and started this from emacs and I had to do a hard
reboot because I could not stop it or break into it. Suggestions for better
ways (magic keystrokes in ubuntu, etc) appreciated.
Because my questions cover several aspects - petitparser, dart, and
ubuntu, I thought I'd try this news group before SO.
First, on the petitparser the following original did not parse like I
final f2 = id & char('(') & any().star() & char(')');
showIt(f2, 'foo(a)', 'as expected');
I opened this question on it
<http://stackoverflow.com/questions/32166750/why-does-any-not-backtrack-in-this-example>.
I thought I'd figured out why the original didn't work and went to remedy
it with the *oops* line above. As I mentioned that did not work out
well. I'm pretty sure the problem with the *oops* line is that it causes
an infinite loop. I'm not sure whether that is expected behavior for
*petitparser* or not.
So, on the dart side of things, in general, under what circumstances can
a dart process bring a machine to a crawl like this?
As a test case I created a simple infinite loop in a dart script and when
run the laptop fan when on, but I was able to move the mouse, select other
apps, and kill the offender. My guess is the reason I could not do that for
the parser script is it's infinite loop was more complex and using
resources without releasing them?
On the unix side, is there an issue with my setup or will the same pretty
much happen on any platform?
Thanks,
Dan
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Lukas Renggli
2015-08-24 16:00:13 UTC
Permalink
I am not aware of a book about PEGs in general, but there are plenty of
papers and tutorials that you can find on the web.

A good starting point with focus on PetitParser is here:
http://scg.unibe.ch/research/helvetia/petitparser. Note that most of these
papers/tutorials/book chapters use the Smalltalk version, but it should be
strait forward to adapt to Dart. If not, feel free to ask.

Cheers,
Lukas
Post by Daniel Davidson
Post by Lukas Renggli
Hi Dan,
I hope that my response on SO answered your question regarding PetitParser?
Yes, thanks. Now it makes sense.
The parser char(')').not().star() loops infinitely. This is expected,
because not() is a predicate that does not consume its input. Check the
class documentation on this function and compare it with the comment on
neg(), which is likely what you wanted.
I see - thanks. I want to do more with this library and have not had
exposure to parser expression grammars. Can you recommend any books
(preferably not dry text books)?
Post by Lukas Renggli
Cheers,
Lukas
I'm playing with petitparser, which is pretty cool and fun. I'm just
Post by Lukas Renggli
Post by Daniel Davidson
getting into it and was caught off guard when the following simple dart
import 'package:petitparser/petitparser.dart';
import 'package:petitparser/debug.dart';
main() {
showIt(p, s, [tag = '']) {
var result = p.parse(s);
$s
123456789123456789
''');
}
final id = letter() & word().star();
final oops = id & char('(') & char(')').not().star() & char(')');
showIt(oops, 'foo(a)', 'as expected');
}
I'm running ubuntu and started this from emacs and I had to do a hard
reboot because I could not stop it or break into it. Suggestions for better
ways (magic keystrokes in ubuntu, etc) appreciated.
Because my questions cover several aspects - petitparser, dart, and
ubuntu, I thought I'd try this news group before SO.
First, on the petitparser the following original did not parse like I
final f2 = id & char('(') & any().star() & char(')');
showIt(f2, 'foo(a)', 'as expected');
I opened this question on it
<http://stackoverflow.com/questions/32166750/why-does-any-not-backtrack-in-this-example>.
I thought I'd figured out why the original didn't work and went to remedy
it with the *oops* line above. As I mentioned that did not work out
well. I'm pretty sure the problem with the *oops* line is that it
causes an infinite loop. I'm not sure whether that is expected behavior for
*petitparser* or not.
So, on the dart side of things, in general, under what circumstances can
a dart process bring a machine to a crawl like this?
As a test case I created a simple infinite loop in a dart script and
when run the laptop fan when on, but I was able to move the mouse, select
other apps, and kill the offender. My guess is the reason I could not do
that for the parser script is it's infinite loop was more complex and using
resources without releasing them?
On the unix side, is there an issue with my setup or will the same
pretty much happen on any platform?
Thanks,
Dan
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Loading...