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

"Encountered context mismatch" trying to debug RegExp-using application #26941

Closed
Hixie opened this issue Jul 21, 2016 · 10 comments

Comments

@Hixie
Copy link
Contributor

commented Jul 21, 2016

I don't have a minimised test case for this but I can reproduce it reliably:

Run through these steps to get yourself a Flutter engine repo:
https://github.com/flutter/engine/blob/master/CONTRIBUTING.md

You shouldn't need to actually build an engine but you may need to at least get the dependencies.

Fetch this branch: https://github.com/Hixie/sky_engine/tree/debugger-crash

Open a terminal in the tools/licenses directory of that repo.

run dart --checked --observe lib/main.dart ../..

It will say "Preparing data structures..." for a while, then "Collecting licenses...", then it will show a progress count. As soon as it shows a progress count (no need to rush, that count will take hours to complete), load up http://localhost:8181/ and click "debug".

The VM crashes with:

-------------------------
Encountered context mismatch
        ctx_slot: 1
        frame_ctx_level: 0
        var_ctx_level: 0

-------------------------
Current frame:
[ Frame pc(0x7fc95924eaa5) fp(0x7fc9f8f45a30) sp(0x7fc9f8f459e8)
        function = <_findLicenseBlocks@17395340_sync_body>
        url = .../engine/src/tools/licenses/lib/licenses.dart
        line = 522
        context = Context num_variables: 1 parent:{ Context num_variables: 7 }
        context level = 0 ]

-------------------------
Context contents:
        Context@0x7fc9d87f5c09 vars(1) {
          [0] = Instance of '_AllMatchesIterator'
          Context@0x7fc9d87f5b99 vars(7) {
            [0] = [first 50 chars:] // Copyright 2015 The Chromium Authors. All rights...
        [1] = [first 50 chars:] RegExp: pattern=((?:[-;#<!/* ]*(?:REM[-;#<!/* ]*)?...
            [2] = 1
            [3] = 2
            [4] = true
            [5] = -1
            [6] = null
          }
        }
-------------------------
Debugger stack trace...

#0000 [ Frame pc(0x7fc9e3faf077) fp(0x7fc9f8f458e0) sp(0x7fc9f8f458c0)
        function = Int32List.[]
        url = dart:typed_data
        line = 1393
        context = Context num_variables: 0
        context level = 0 ]
#0001 [ Frame pc(0x7fc9e27006a5) fp(0x7fc9f8f45988) sp(0x7fc9f8f458f0)
        function = RegExp.:matcher: ((?:[-;#<!/* ]*(?:REM[-;#<!/* ]*)?[-;#<!/*]+)?)( *)The .+ is licensed pursuant to the OpenSSL open source *\n^(?:\1|\2| )* license provided (?:below|above)\.
        url = dart:core/regexp.dart
        line = -1
        context = Context num_variables: 0
        context level = 0 ]
#0002 [ Frame pc(0x7fc97f38c156) fp(0x7fc9f8f459d8) sp(0x7fc9f8f45998)
        function = _AllMatchesIterator@0150898.moveNext
        url = dart:core-patch/regexp_patch.dart
        line = 268
        context = Context num_variables: 0
        context level = 0 ]
...

I can provide a full crash log on request.

@johnmccutchan

This comment has been minimized.

Copy link
Member

commented Jul 21, 2016

@johnmccutchan

This comment has been minimized.

Copy link
Member

commented Jul 21, 2016

Also @turnidge FYI

@a-siva a-siva assigned a-siva and crelier and unassigned a-siva Jul 21, 2016

@crelier

This comment has been minimized.

Copy link
Member

commented Jul 22, 2016

Not knowing the proper git incantation to fetch your branch, I just downloaded the zip file and expanded it on top of my flutter engine.

When running the command dart --checked --observe lib/main.dart ../..
I get this error immediately:
Load Error for "package:archive/archive.dart": Could not resolve a package location for base at file:///usr/local/google/home/regis/flutter/engine/src/tools/licenses/lib/main.dart

The dart executable comes from here:
regis@belenos:~/flutter/engine/src/tools/licenses$ which dart
/usr/local/google/home/regis/flutter/engine/src/third_party/dart-sdk/dart-sdk/bin/dart

Am I supposed to point the packages root to somewhere?

@Hixie

This comment has been minimized.

Copy link
Contributor Author

commented Jul 22, 2016

Oh, sorry, missed a step. Run pub get in tools/licenses first.

@crelier

This comment has been minimized.

Copy link
Member

commented Jul 22, 2016

Thanks! That helped. I can see the progress count, so I need to be patient now.
I got this error while running pub get, which I am not sure I can safely ignore:
A transformer imported unknown package "args" (in "package:args/args.dart").

@johnmccutchan

This comment has been minimized.

Copy link
Member

commented Jul 25, 2016

Might be related: #26948

@crelier

This comment has been minimized.

Copy link
Member

commented Jul 25, 2016

Thanks! Indeed, it could be related.
Adding @mhausner

I am adding the full stack trace which may be helpful in debugging:


Debugger stack trace...

#0000 [ Frame pc(0x7fb15374d203) fp(0x7fb153ffd920) sp(0x7fb153ffd900)
function = Int32Array@100690443.[]=
url = dart:typed_data-patch/typed_data.dart
line = 1187
context = Context num_variables: 0
context level = 0 ]
#1 [ Frame pc(0x7fb0bb7c2463) fp(0x7fb153ffd9d0) sp(0x7fb153ffd930)
function = RegExp.:irregexp: ^((?:[-;#<!/* ]
(?:REM[-;#<!/_ ])?[-;#<!/]+)?)( _)Permission *(?:\n\1\2)? *is *(?:\n\1\2)? *hereby *(?:\n\1\2)? *granted, *(?:\n\1\2)? *free *(?:\n\1\2)? *of *(?:\n\1\2)? *charge, *(?:\n\1\2)? *to *(?:\n\1\2)? *any *(?:\n\1\2)? *person *(?:\n\1\2)? *obtaining *(?:\n\1\2)? *a *(?:\n\1\2)? *copy *(?:\n\1\2)? *of *(?:\n\1\2)? *this *(?:\n\1\2)? *software *(?:\n\1\2)? *and *(?:\n\1\2)? *associated *(?:\n\1\2)? *documentation *(?:\n\1\2)? *files *(?:\n\1\2)? *(the *(?:\n\1\2)? *"Software"), *(?:\n\1\2)? *to *(?:\n\1\2)? *deal *(?:\n\1\2)? *in *(?:\n\1\2)? *the *(?:\n\1\2)? *Software *(?:\n\1\2)? *without *(?:\n\1\2)? *restriction, *(?:\n\1\2)? *including *(?:\n\1\2)? *without *(?:\n\1\2)? *limitation *(?:\n\1\2)? *the *(?:\n\1\2)? *rights *(?:\n\1\2)? *to *(?:\n\1\2)? *use, *(?:\n\1\2)? *copy, *(?:\n\1\2)? *modify, *(?:\n\1\2)? *merge, *(?:\n\1\2)? *publish, *(?:\n\1\2)? *distribute, *(?:\n\1\2)? *sublicense, *(?:\n\1\2)? *and/or *(?:\n\1\2)? *sell *(?:\n\1\2)? *copies *(?:\n\1\2)? *of *(?:\n\1\2)? *the *(?:\n\1\2)? *Software, *(?:\n\1\2)? *and *(?:\n\1\2)? *to *(?:\n\1\2)? *permit *(?:\n\1\2)? *persons *(?:\n\1\2)? *to *(?:\n\1\2)? *whom *(?:\n\1\2)? *the *(?:\n\1\2)? *Software *(?:\n\1\2)? *is *(?:\n\1\2)? *furnished *(?:\n\1\2)? *to *(?:\n\1\2)? *do *(?:\n\1\2)? *so, *(?:\n\1\2)? *subject *(?:\n\1\2)? *to *(?:\n\1\2)? *the *(?:\n\1\2)? *following *(?:\n\1\2)? *conditions:(?:(?:\1\2? *)? *\n)_The _(?:\n\1\2)? *above *(?:\n\1\2)? *copyright *(?:\n\1\2)? *notice *(?:\n\1\2)? *and *(?:\n\1\2)? *this *(?:\n\1\2)? *permission *(?:\n\1\2)? *notice *(?:\n\1\2)? *shall *(?:\n\1\2)? *be *(?:\n\1\2)? *included *(?:\n\1\2)? *in *(?:\n\1\2)? *all *(?:\n\1\2)? *copies *(?:\n\1\2)? *or *(?:\n\1\2)? *substantial *(?:\n\1\2)? *portions *(?:\n\1\2)? *of *(?:\n\1\2)? *the *(?:\n\1\2)? *Software.(?:(?:\1\2? *)? *\n)_THE *(?:\n\1\2)? *SOFTWARE *(?:\n\1\2)? *IS *(?:\n\1\2)? *PROVIDED *(?:\n\1\2)? *"AS *(?:\n\1\2)? *IS", *(?:\n\1\2)? *WITHOUT *(?:\n\1\2)? *WARRANTY *(?:\n\1\2)? *OF *(?:\n\1\2)? *ANY *(?:\n\1\2)? *KIND, *(?:\n\1\2)? *EXPRESS *(?:\n\1\2)? *OR *(?:\n\1\2)? *IMPLIED, *(?:\n\1\2)? *INCLUDING *(?:\n\1\2)? *BUT *(?:\n\1\2)? *NOT *(?:\n\1\2)? *LIMITED *(?:\n\1\2)? *TO *(?:\n\1\2)? *THE *(?:\n\1\2)? *WARRANTIES *(?:\n\1\2)? *OF *(?:\n\1\2)? *MERCHANTABILITY, *(?:\n\1\2)? *FITNESS *(?:\n\1\2)? *FOR *(?:\n\1\2)? *A *(?:\n\1\2)? *PARTICULAR *(?:\n\1\2)? *PURPOSE *(?:\n\1\2)? *AND *(?:\n\1\2)? *NONINFRINGEMENT. *(?:\n\1\2)? *IN *(?:\n\1\2)? *NO *(?:\n\1\2)? *EVENT *(?:\n\1\2)? *SHALL *(?:\n\1\2)? *THE *(?:\n\1\2)? *AUTHORS *(?:\n\1\2)? *BE *(?:\n\1\2)? *LIABLE *(?:\n\1\2)? *FOR *(?:\n\1\2)? *ANY *(?:\n\1\2)? *CLAIM, *(?:\n\1\2)? *DAMAGES *(?:\n\1\2)? *OR *(?:\n\1\2)? *OTHER *(?:\n\1\2)? *LIABILITY, *(?:\n\1\2)? *WHETHER *(?:\n\1\2)? *IN *(?:\n\1\2)? *AN *(?:\n\1\2)? *ACTION *(?:\n\1\2)? *OF *(?:\n\1\2)? *CONTRACT, *(?:\n\1\2)? *TORT *(?:\n\1\2)? *OR *(?:\n\1\2)? *OTHERWISE, *(?:\n\1\2)? *ARISING *(?:\n\1\2)? *FROM, *(?:\n\1\2)? *OUT *(?:\n\1\2)? *OF *(?:\n\1\2)? *OR *(?:\n\1\2)? *IN *(?:\n\1\2)? *CONNECTION *(?:\n\1\2)? *WITH *(?:\n\1\2)? *THE *(?:\n\1\2)? *SOFTWARE *(?:\n\1\2)? *OR *(?:\n\1\2)? *THE *(?:\n\1\2)? *USE *(?:\n\1\2)? *OR *(?:\n\1\2)? *OTHER *(?:\n\1\2)? *DEALINGS *(?:\n\1\2)? *IN *(?:\n\1\2)? *THE *(?:\n\1\2)? *SOFTWARE.
url = dart:core/regexp.dart
line = -1
context = Context num_variables: 0
context level = 0 ]
#2 [ Frame pc(0x7fb153873f89) fp(0x7fb153ffda20) sp(0x7fb153ffd9e0)
function = _AllMatchesIterator@915557746.moveNext
url = dart:core-patch/regexp_patch.dart
line = 268
context = Context num_variables: 0
context level = 0 ]
#3 [ Frame pc(0x7fb0c20f59a6) fp(0x7fb153ffda80) sp(0x7fb153ffda30)
function = _findLicenseBlocks@35923893_sync_body
url = file:///usr/local/google/home/regis/flutter/engine/src/tools/licenses/lib/licenses.dart
line = 522
context = Context num_variables: 1 parent:{ Context num_variables: 7 }
context level = 0 ]
#4 [ Frame pc(0x7fb153e7a9f8) fp(0x7fb153ffdad8) sp(0x7fb153ffda90)
function = _SyncIterator@915557746.moveNext
url = dart:core-patch/core_patch.dart
line = 61
context = Context num_variables: 0
context level = 0 ]
#5 [ Frame pc(0x7fb0c1be8a6f) fp(0x7fb153ffdb10) sp(0x7fb153ffdae8)
function = _tryInline@35923893_sync_body
url = file:///usr/local/google/home/regis/flutter/engine/src/tools/licenses/lib/licenses.dart
line = 704
context = Context num_variables: 1 parent:{ Context num_variables: 5 }
context level = 0 ]
#6 [ Frame pc(0x7fb153e7a9f8) fp(0x7fb153ffdb68) sp(0x7fb153ffdb20)
function = _SyncIterator@915557746.moveNext
url = dart:core-patch/core_patch.dart
line = 61
context = Context num_variables: 0
context level = 0 ]
#7 [ Frame pc(0x7fb13261a27a) fp(0x7fb153ffdbd0) sp(0x7fb153ffdb78)
function = ExpandIterator.moveNext
url = dart:_internal/iterable.dart
line = 472
context = Context num_variables: 0
context level = 0 ]
#8 [ Frame pc(0x7fb1326192ad) fp(0x7fb153ffdc48) sp(0x7fb153ffdbe0)
function = _GrowableList@915557746.addAll
url = dart:core-patch/growable_array.dart
line = 182
context = Context num_variables: 0
context level = 0 ]
#9 [ Frame pc(0x7fb13261d40a) fp(0x7fb153ffdcb8) sp(0x7fb153ffdc58)
function = determineLicensesFor
url = file:///usr/local/google/home/regis/flutter/engine/src/tools/licenses/lib/licenses.dart
line = 730
context = Context num_variables: 4
context level = 1 ]
#10 [ Frame pc(0x7fb13262835f) fp(0x7fb153ffdd28) sp(0x7fb153ffdcc8)
function = RepositorySourceFile.get:licenses
url = file:///usr/local/google/home/regis/flutter/engine/src/tools/licenses/lib/main.dart
line = 82
context = Context num_variables: 1
context level = 1 ]
#11 [ Frame pc(0x7fb132631a7b) fp(0x7fb153ffdda0) sp(0x7fb153ffdd38)
function = RepositoryDirectory.getLicenses
url = file:///usr/local/google/home/regis/flutter/engine/src/tools/licenses/lib/main.dart
line = 938
context = Context num_variables: 0
context level = 0 ]
#12 [ Frame pc(0x7fb1326315b0) fp(0x7fb153ffde28) sp(0x7fb153ffddb0)
function = RepositoryDirectory.getLicenses
url = file:///usr/local/google/home/regis/flutter/engine/src/tools/licenses/lib/main.dart
line = 934
context = Context num_variables: 0
context level = 0 ]
#13 [ Frame pc(0x7fb1326315b0) fp(0x7fb153ffdeb0) sp(0x7fb153ffde38)
function = RepositoryDirectory.getLicenses
url = file:///usr/local/google/home/regis/flutter/engine/src/tools/licenses/lib/main.dart
line = 934
context = Context num_variables: 0
context level = 0 ]
#14 [ Frame pc(0x7fb1326315b0) fp(0x7fb153ffdf38) sp(0x7fb153ffdec0)
function = RepositoryDirectory.getLicenses
url = file:///usr/local/google/home/regis/flutter/engine/src/tools/licenses/lib/main.dart
line = 934
context = Context num_variables: 0
context level = 0 ]
#15 [ Frame pc(0x7fb153e4eea6) fp(0x7fb153ffdfa8) sp(0x7fb153ffdf48)
function = main
url = file:///usr/local/google/home/regis/flutter/engine/src/tools/licenses/lib/main.dart
line = 1477
context = Context num_variables: 3 parent:{ Context num_variables: 0 }
context level = 1 ]
#16 [ Frame pc(0x7fb153e4e3c4) fp(0x7fb153ffe068) sp(0x7fb153ffe038)
function =
url = dart:isolate-patch/isolate_patch.dart
line = 259
context = Context num_variables: 5
context level = 0 ]
#17 [ Frame pc(0x7fb15396de47) fp(0x7fb153ffe0f0) sp(0x7fb153ffe0c0)
function = _RawReceivePortImpl@709387912._handleMessage@709387912
url = dart:isolate-patch/isolate_patch.dart
line = 148
context = Context num_variables: 0

context level = 0 ]

@johnmccutchan

This comment has been minimized.

Copy link
Member

commented Jul 25, 2016

@Hixie Can you confirm that you also saw an issue where regular expressions stopped making progress? We might need to block Dart 1.18 release on this issue.

@Hixie

This comment has been minimized.

Copy link
Contributor Author

commented Jul 26, 2016

I thought I did, but further study suggested I just had pathological expressions and they were just taking forever to complete. (That's why I was trying to connect the debugger, to find out what expression was the problem.)

@crelier

This comment has been minimized.

Copy link
Member

commented Jul 27, 2016

Unfortunately, the fix for #26948 does not fix this issue.

In debug mode, the debugger crashes with an assert fault before reporting the context mismatch:

runtime/vm/object.cc: 237: error: expected: strlen(cname) == static_cast<size_t>(name.Length())

It looks like the debugger is having trouble scrubbing a name containing a regexp. At least, the length is not consistent (e.g. 6478 vs 6482). The same inconsistency exists in release mode, before the context mismatch is reported. But I verified that the mismatch is not a consequence of scrubbing the name.

Let me dig deeper...

@crelier crelier closed this in 47cf4c1 Jul 28, 2016

@crelier crelier reopened this Jul 28, 2016

crelier added a commit that referenced this issue Jul 29, 2016
Set correct token position range for statement block containing moveN…
…ext call of

for-in loops (second attempt at fixing #26941).

R=hausner@google.com

Review URL: https://codereview.chromium.org/2193113002 .

@crelier crelier closed this Jul 29, 2016

whesse added a commit that referenced this issue Aug 2, 2016
Set correct token position range for statement block containing moveN…
…ext call of

for-in loops (second attempt at fixing #26941).

R=hausner@google.com

Review URL: https://codereview.chromium.org/2193113002 .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.