Daniel Davidson
2015-08-23 13:55:35 UTC
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
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.
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.