dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.27k stars 1.58k forks source link

custom transformer fails with stack overflow #20915

Closed DartBot closed 9 years ago

DartBot commented 10 years ago

This issue was originally filed by @zoechi


I have a simple transformer that basically does nothing but fails with a stack overflow.

library bwu_testrunner.transformer;

import 'dart:async' as async; import 'package:barback/barback.dart';

class HtmlTestTransformer extends Transformer {

  HtmlTestTransformer.asPlugin();

  static final htmlUnitTest = new RegExp(r'''(?:[\s\S]?\s?)(import\s["']package:unittest/html_config.dart\1)(?:[\s\S]?)((void )+main((?:[\s\S]?))(?:[\s\S]?){)''');   static final importEnd = new RegExp(r'''([\s\S]?\s?import\s["']package:unittest/html_config.dart\1[\s\S]?\n)''');

  apply(Transform transform) {     // return; doesn't matter if this is commented in or not     return transform.primaryInput.readAsString()     .then((String content) {       var isHtmlUnitTest = htmlUnitTest.firstMatch(content) != null;       var match = importEnd.firstMatch(content);       if(isHtmlUnitTest && match != null) {         var newContent = content.substring(0, match.end) + "import 'package:bwu_testrunner/server/browser_testrunner.dart';\n" + content.substring(match.end);         transform.addOutput(new Asset.fromString(transform.primaryInput.id, newContent));       }     });   }

  async.Future<bool> isPrimary(AssetId id) {     var isValid = true;     if(!['.html'].contains(id.extension)) isValid = false;     if(!id.path.startsWith('test/')) isValid = false;     //return new async.Future.value(isValid);     return new async.Future.value(false); // even when I always return false or always true   } }

 (master) $ pub serve --trace Loading source assets... (6.2s) Stack Overflow /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/lib/src/utils.dart 53 syncFuture /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/lib/src/command.dart 113 PubCommand.run /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 133 invokeCommand.<fn>.break0.join0 /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 143 invokeCommand.<fn>.break0 /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 201 invokeCommand.<fn>.continue0 /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 155 invokeCommand.<fn>.continue0.<fn>.join2.join3 /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 161 invokeCommand.<fn>.continue0.<fn>.join2 /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 197 invokeCommand.<fn>.continue0.<fn> dart:isolate _RawReceivePortImpl._handleMessage ===== asynchronous gap =========================== dart:async _Future.then /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 148 invokeCommand.<fn>.continue0 /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 204 invokeCommand.<fn> dart:isolate _RawReceivePortImpl._handleMessage ===== asynchronous gap =========================== dart:async scheduleMicrotask /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 112 invokeCommand /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 75 runPub.<fn> dart:async Future.Future.sync /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/lib/src/utils.dart 57 captureErrors.<fn> package:stack_trace/src/chain.dart 93 Chain.capture /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/lib/src/utils.dart 68 captureErrors /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 74 runPub /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 67 main.<fn> dart:isolate _RawReceivePortImpl._handleMessage

---- Log transcript ---- FINE: Pub 1.7.0-edge.40150 FINE: Clean up system cache temp directory /home/zoechi/.pub-cache/_temp. FINE: Loaded package graph. FINE: Initializing barback... FINE: Serving packages on localhost:0. FINE: Providing sources for bwu_utils_browser|lib. FINE: Providing sources for browser|lib. FINE: Providing sources for http_server|lib. FINE: Providing sources for uuid|lib. FINE: Providing sources for petitparser|lib. FINE: Providing sources for matcher|lib. FINE: Providing sources for bwu_sparkline|lib. FINE: Providing sources for core_elements|lib. FINE: Providing sources for utf|lib. FINE: Providing sources for source_span|lib. FINE: Providing sources for string_scanner|lib. FINE: Providing sources for web_components|lib. FINE: Providing sources for source_maps|lib. FINE: Providing sources for mime|lib. FINE: Providing sources for logging_handlers|lib. FINE: Providing sources for bwu_utils|lib. FINE: Providing sources for watcher|lib. FINE: Providing sources for quiver|lib. FINE: Providing sources for args|lib. FINE: Providing sources for collection|lib. FINE: Providing sources for bwu_testrunner|lib. FINE: Providing sources for crypto|lib. FINE: Providing sources for barback|lib. FINE: Providing sources for code_transformers|lib. FINE: Providing sources for pool|lib. FINE: Providing sources for cipher|lib. FINE: Providing sources for bignum|lib. FINE: Providing sources for csslib|lib. FINE: Providing sources for template_binding|lib. FINE: Providing sources for polymer|lib. FINE: Providing sources for paper_elements|lib. FINE: Providing sources for smoke|lib. FINE: Providing sources for stack_trace|lib. FINE: Providing sources for intl|lib. FINE: Providing sources for html5lib|lib. FINE: Providing sources for fixnum|lib. FINE: Providing sources for bwu_datagrid|lib. FINE: Providing sources for path|lib. FINE: Providing sources for quiver_log|lib. FINE: Providing sources for bwu_fontawesome_iconset_svg|lib. FINE: Providing sources for observe|lib. FINE: Providing sources for logging|lib. FINE: Providing sources for yaml|lib. FINE: Providing sources for unittest|lib. FINE: Providing sources for analyzer|lib. FINE: Providing sources for polymer_expressions|lib. FINE: Providing sources for bwu_datagrid_playground|lib. IO : Spawning "git --version" in /home/zoechi/source/my/dart/bwu_datagrid_playground/. IO : Finished git. Exit code 0.     | stdout:     | | git version 2.1.0     | Nothing output on stderr. FINE: Determined git command null. IO : Spawning "git ls-files --cached --others --exclude-standard lib" in /home/zoechi/source/my/dart/bwu_datagrid_playground/../bwu_datagrid IO : Finished git. Exit code 0.     | stdout:     | | lib/asset/default_theme.css     | | lib/asset/grid.css     | | lib/asset/images/actions.gif     | | lib/asset/images/ajax-loader-small.gif     | | lib/asset/images/arrow_redo.png     | | lib/asset/images/arrow_right_peppermint.png     | | lib/asset/images/arrow_right_spearmint.png     | | lib/asset/images/arrow_undo.png     | | lib/asset/images/bullet_blue.png     | | lib/asset/images/bullet_star.png     | | lib/asset/images/bullet_toggle_minus.png     | | lib/asset/images/bullet_toggle_plus.png     | | lib/asset/images/calendar.gif     | | lib/asset/images/collapse.gif     | | lib/asset/images/comment_yellow.gif     | | lib/asset/images/down.gif     | | lib/asset/images/drag-handle.png     | | lib/asset/images/editor-helper-bg.gif     | | lib/asset/images/expand.gif     | | lib/asset/images/header-bg.gif     | | lib/asset/images/header-columns-bg.gif     | | lib/asset/images/header-columns-over-bg.gif     | | lib/asset/images/help.png     | | lib/asset/images/info.gif     | | lib/asset/images/listview.gif     | | lib/asset/images/pencil.gif     | | lib/asset/images/row-over-bg.gif     | | lib/asset/images/sort-asc.gif     | | lib/asset/images/sort-asc.png     | | lib/asset/images/sort-desc.gif     | | lib/asset/images/sort-desc.png     | | lib/asset/images/stripes.png     | | lib/asset/images/tag_red.png     | | lib/asset/images/tick.png     | | lib/asset/images/user_identity.gif     | | lib/asset/images/user_identity_plus.gif     | | lib/asset/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png     | | lib/asset/smoothness/images/ui-bg_flat_75_ffffff_40x100.png     | | lib/asset/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png     | | lib/asset/smoothness/images/ui-bg_glass_65_ffffff_1x400.png     | | lib/asset/smoothness/images/ui-bg_glass_75_dadada_1x400.png     | | lib/asset/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png     | | lib/asset/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png     | | lib/asset/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png     | | lib/asset/smoothness/images/ui-icons_222222_256x240.png     | | lib/asset/smoothness/images/ui-icons_2e83ff_256x240.png     | | lib/asset/smoothness/images/ui-icons_454545_256x240.png     | | lib/asset/smoothness/images/ui-icons_888888_256x240.png     | | lib/asset/smoothness/images/ui-icons_cd0a0a_256x240.png     | | lib/asset/smoothness/jquery-ui-1.8.16.custom.css     | | lib/bwu_datagrid.dart     | | lib/bwu_datagrid.html     | | lib/components/bwu_column_picker/bwu_column_picker.css     | | lib/components/bwu_column_picker/bwu_column_picker.dart     | | lib/components/bwu_column_picker/bwu_column_picker.html     | | lib/components/bwu_pager/bwu_pager.css     | | lib/components/bwu_pager/bwu_pager.dart     | | lib/components/bwu_pager/bwu_pager.html     | | lib/core/core.dart     | | lib/core/event_bus.dart     | | lib/core/event_data.dart     | | lib/core/range.dart     | | lib/datagrid/bwu_datagrid_header_column.css     | | lib/datagrid/bwu_datagrid_header_column.dart     | | lib/datagrid/bwu_datagrid_header_column.html     | | lib/datagrid/bwu_datagrid_header_column_default_theme.css     | | lib/datagrid/bwu_datagrid_headerrow_column.css     | | lib/datagrid/bwu_datagrid_headerrow_column.dart     | | lib/datagrid/bwu_datagrid_headerrow_column.html     | | lib/datagrid/bwu_datagrid_headerrow_column_default_theme.css     | | lib/datagrid/bwu_datagrid_headers.css     | | lib/datagrid/bwu_datagrid_headers.dart     | | lib/datagrid/bwu_datagrid_headers.html     | | lib/datagrid/bwu_datagrid_headers_default_theme.css     | | lib/datagrid/helpers.dart     | | lib/dataview/aggregators.dart     | | lib/dataview/dataview.dart     | | lib/dataview/helpers.dart     | | lib/editors/editors.dart     | | lib/effects/sortable.dart     | | lib/formatters/formatters.dart     | | lib/groupitem_metadata_providers/groupitem_metadata_providers.dart     | | lib/libraries.dart     | | lib/plugins/bwu_auto_tooltips.dart     | | lib/plugins/cell_copymanager.dart     | | lib/plugins/cell_range_decorator.dart     | | lib/plugins/cell_range_selector.dart     | | lib/plugins/cell_selection_model.dart     | | lib/plugins/checkbox_select_column.dart     | | lib/plugins/plugin.dart     | | lib/plugins/row_move_manager.dart     | | lib/plugins/row_selection_model.dart     | | lib/remote_model/remote_model.dart     | Nothing output on stderr. IO : Spawning "git ls-files --cached --others --exclude-standard lib" in /home/zoechi/source/my/dart/bwu_datagrid_playground/../bwu_testrunner IO : Finished git. Exit code 0.     | stdout:     | | lib/client/components/app_element.css     | | lib/args.dart     | | lib/client/client.dart     | | lib/client/components/app_element.dart     | | lib/client/components/app_element.html     | | lib/client/components/app_element.scss     | | lib/client/components/grid_helpers.dart     | | lib/client/connection.dart     | | lib/config.dart     | | lib/console_launcher.dart     | | lib/content_shell.dart     | | lib/content_shell_launcher.dart     | | lib/launcher.dart     | | lib/pub_serve.dart     | | lib/result.dart     | | lib/result_report.dart     | | lib/result_report_print.dart     | | lib/server/browser_testrunner.dart     | | lib/server/isolate_testrunner.dart     | | lib/server/logging_handler.dart     | | lib/server/process_testrunner.dart     | | lib/server/server.dart     | | lib/server/test_launcher.dart     | | lib/server/testfiles.dart     | | lib/server/unittest_configuration.dart     | | lib/shared/message.dart     | | lib/shared/response_collector.dart     | | lib/shared/response_completer.dart     | | lib/shared/response_forwarder.dart     | | lib/timeout_manager.dart     | | lib/transformer.dart     | | lib/util.dart     | Nothing output on stderr. FINE: Loading source assets finished (6.2s). FINE: Provided sources. FINE: Loading transformers... FINE: Transformer dependencies:     | bwu_testrunner: polymer, polymer/src/build/mirrors_remover, polymer/src/build/delete_file, polymer/src/build/remove_sourcemap_comment, observe, smoke/src/default_transformer and bwu_testrunner     | polymer: smoke/src/default_transformer     | polymer/src/build/mirrors_remover: -     | polymer/src/build/delete_file: -     | polymer/src/build/remove_sourcemap_comment: -     | observe: -     | smoke/src/default_transformer: - FINE: Initializing barback finished (7.9s). ERR : Stack Overflow FINE: Exception type: StackOverflowError ERR : /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/lib/src/utils.dart 53 syncFuture     | /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/lib/src/command.dart 113 PubCommand.run     | /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 133 invokeCommand.<fn>.break0.join0     | /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 143 invokeCommand.<fn>.break0     | /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 201 invokeCommand.<fn>.continue0     | /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 155 invokeCommand.<fn>.continue0.<fn>.join2.join3     | /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 161 invokeCommand.<fn>.continue0.<fn>.join2     | /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 197 invokeCommand.<fn>.continue0.<fn>     | dart:isolate _RawReceivePortImpl._handleMessage     | ===== asynchronous gap ===========================     | dart:async _Future.then     | /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 148 invokeCommand.<fn>.continue0     | /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 204 invokeCommand.<fn>     | dart:isolate _RawReceivePortImpl._handleMessage     | ===== asynchronous gap ===========================     | dart:async scheduleMicrotask     | /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 112 invokeCommand     | /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 75 runPub.<fn>     | dart:async Future.Future.sync     | /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/lib/src/utils.dart 57 captureErrors.<fn>     | package:stack_trace/src/chain.dart 93 Chain.capture     | /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/lib/src/utils.dart 68 captureErrors     | /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 74 runPub     | /mnt/data/b/build/slave/dart-editor-linux-be/build/dart/sdk/lib/_internal/pub_generated/bin/pub.dart 67 main.<fn>     | dart:isolate _RawReceivePortImpl._handleMessage

---- End log transcript ----

mit-mit commented 9 years ago

Closing as stale. If this is still an issue, please file a new bug.