Skip to content

Compiler crash: Iterables do not have same length #53453

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

Closed
burekas7 opened this issue Sep 7, 2023 · 21 comments
Closed

Compiler crash: Iterables do not have same length #53453

burekas7 opened this issue Sep 7, 2023 · 21 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Comments

@burekas7
Copy link

burekas7 commented Sep 7, 2023

Flutter 3.13.2
environment:
sdk: '>=3.1.0 <4.0.0'


After a specific dio 'post' call I'm getting this error:

Unhandled exception:
Invalid argument(s): Iterables do not have same length.
#0      MapBase._fillMapWithIterables (dart:collection/maps.dart:178:7)
#1      new LinkedHashMap.fromIterables (dart:collection/linked_hash_map.dart:246:13)
#2      Substitution.fromPairs (package:kernel/type_algebra.dart:263:13)
#3      InferenceVisitorBase.getGetterTypeForMemberTarget (package:front_end/src/fasta/type_inference/inference_visitor_base.dart:1465:35)
#4      InstanceAccessTarget.getGetterType (package:front_end/src/fasta/type_inference/object_access_target.dart:489:30)
#5      InferenceVisitorImpl._computePropertyGet (package:front_end/src/fasta/type_inference/inference_visitor.dart:6663:36)
#6      InferenceVisitorImpl.visitPropertyGet (package:front_end/src/fasta/type_inference/inference_visitor.dart:7672:61)
#7      PropertyGet.acceptInference (package:front_end/src/fasta/kernel/internal_ast.dart:2984:20)

#8      InferenceVisitorImpl._inferExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:257:27)
#9      InferenceVisitorImpl.inferNullAwareExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:310:40)
#10     InferenceVisitorImpl.visitIndexGet (package:front_end/src/fasta/type_inference/inference_visitor.dart:5227:48)
#11     IndexGet.acceptInference (package:front_end/src/fasta/kernel/internal_ast.dart:1824:20)
#12     InferenceVisitorImpl._inferExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:257:27)
#13     InferenceVisitorImpl.inferNullAwareExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:310:40)
#14     InferenceVisitorImpl.visitIndexGet (package:front_end/src/fasta/type_inference/inference_visitor.dart:5227:48)
#15     IndexGet.acceptInference (package:front_end/src/fasta/kernel/internal_ast.dart:1824:20)
#16     InferenceVisitorImpl._inferExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:257:27)
#17     InferenceVisitorImpl.inferNullAwareExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:310:40)
#18     InferenceVisitorImpl.visitIndexGet (package:front_end/src/fasta/type_inference/inference_visitor.dart:5227:48)
#19     IndexGet.acceptInference (package:front_end/src/fasta/kernel/internal_ast.dart:1824:20)
#20     InferenceVisitorImpl._inferExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:257:27)
#21     InferenceVisitorImpl.inferNullAwareExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:310:40)
#22     InferenceVisitorImpl.visitIndexGet (package:front_end/src/fasta/type_inference/inference_visitor.dart:5227:48)
#23     IndexGet.acceptInference (package:front_end/src/fasta/kernel/internal_ast.dart:1824:20)
#24     InferenceVisitorImpl._inferExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:257:27)
#25     InferenceVisitorImpl.inferNullAwareExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:310:40)
#26     InferenceVisitorImpl.visitIndexGet (package:front_end/src/fasta/type_inference/inference_visitor.dart:5227:48)
#27     IndexGet.acceptInference (package:front_end/src/fasta/kernel/internal_ast.dart:1824:20)
#28     InferenceVisitorImpl._inferExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:257:27)
#29     InferenceVisitorImpl.inferExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:291:40)
#30     InferenceVisitorImpl.visitReturnStatement (package:front_end/src/fasta/type_inference/inference_visitor.dart:7894:11)
#31     ReturnStatement.accept (package:kernel/ast.dart:10127:43)
#32     InferenceVisitorImpl.inferStatement (package:front_end/src/fasta/type_inference/inference_visitor.dart:242:26)
#33     TypeInferrerImpl.inferFunctionBody (package:front_end/src/fasta/type_inference/type_inferrer.dart:198:17)
#34     BodyBuilder.parseSingleExpression (package:front_end/src/fasta/kernel/body_builder.dart:1780:62)
#35     SourceLoader.buildExpression (package:front_end/src/fasta/source/source_loader.dart:1320:21)
<asynchronous suspension>
#36     IncrementalCompiler.compileExpression.<anonymous closure> (package:front_end/src/fasta/incremental_compiler.dart:2033:39)
<asynchronous suspension>
#37     IncrementalCompiler.compileExpression (package:front_end/src/fasta/incremental_compiler.dart:1853:12)
<asynchronous suspension>
#38     FrontendCompiler.compileExpression (package:frontend_server/frontend_server.dart:981:28)

<asynchronous suspension>
#39     listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1452:11)
<asynchronous suspension>

3
the Dart compiler exited unexpectedly.
Exited (1)
@lrhn lrhn added the legacy-area-front-end Legacy: Use area-dart-model instead. label Sep 7, 2023
@johnniwinther johnniwinther self-assigned this Sep 7, 2023
@johnniwinther
Copy link
Member

@burekas7 Did this happen when evaluation an explicit expression during debugging or when hovering expressions in the editor? Also was this part of a hot-reload cycle (i.e. was the code "recently" modified) ?

@heshesh2010
Copy link

heshesh2010 commented Sep 7, 2023

+1 , got same error when hovering on the expressions in VS CODE editor , using Dio package to debug the responses .

sdk: ">=2.19.2 <4.0.0"

flutter doctor
`Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.13.2, on macOS 13.5 22G74 darwin-x64, locale en-EG)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] VS Code (version 1.81.1)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!`

@johnniwinther
Copy link
Member

@heshesh2010 Do you have any idea what expression was?

@ChaserVasya
Copy link

same

@cmdrKhonan
Copy link

+1 here having a similar issue :

     List<List<int>> l = List.generate(list.length, (index) => []);
     List<dynamic> guide = [
       {
         "field": null,
         "nextList": null,
         "selection": l,
         "max_selected": 1000,
       }
     ];

this generate a debugger crash :

Unhandled exception:
Invalid argument(s): Iterables do not have same length.
#0      MapBase._fillMapWithIterables (dart:collection/maps.dart:178:7)
#1      new LinkedHashMap.fromIterables (dart:collection/linked_hash_map.dart:246:13)
#2      Substitution.fromPairs (package:kernel/type_algebra.dart:263:13)
#3      InferenceVisitorBase.getGetterTypeForMemberTarget (package:front_end/src/fasta/type_inference/inference_visitor_base.dart:1465:35)

@johnniwinther
Copy link
Member

This seems to originate from a bad encoding of the arguments passed to the expression compiler - at least I can recreate the crash by creating such a bad message. I'm still not still sure the where in the tool chain this encoding is created, though.

Likely related to #53382

@johnniwinther
Copy link
Member

cc @jensjoha

@johnniwinther
Copy link
Member

@jensjoha @mraleph Can we be sure that a raw type of a generic class in the VM has the right number of types arguments? I.e. could the VM be creating the encoding ["dart:core", "List", "1", "0"] for List in CollectStringifiedType ?

@mraleph
Copy link
Member

mraleph commented Sep 11, 2023

@johnniwinther I think they should have correct length. Type object in the VM should carry TAV which matches the number of type parameters the class has (cc @alexmarkov)

However the code in CollectStringifiedType is a bit suspicious - it does not seem to handle raw types (e.g. List<dynamic>) correctly. VM used to denote those using null TAV and CollectStringifiedType does not seem to handle that at all. Maybe we can try to reproduce by trying expression compilation in a context with a variable which has a raw type, e.g. final v = <dynamic>[] and see if it blows up?

@mraleph
Copy link
Member

mraleph commented Sep 11, 2023

Yeah it reproduces quite trivially with the following test:

Regression test
import 'dart:developer';
import 'package:observatory/models.dart' show InstanceKind;
import 'package:observatory/service_io.dart';
import 'package:test/test.dart';

import 'service_test_common.dart';
import 'test_helper.dart';

void testFunction() {
  List<dynamic> v = <dynamic>[1, 2, '3'];
  debugger();
  print("v = $v");
}

var tests = <IsolateTest>[
  hasStoppedAtBreakpoint,
  (Isolate isolate) async {
    final result = await isolate.evalFrame(0, '''v.length''');
    print(result);
    final instance = result as Instance;
    expect(instance.valueAsString, equals('3'));
    expect(instance.kind, equals(InstanceKind.int));
  },
];

main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction);

And if I put RELEASE_ASSERT(!srcArguments.IsNull()); it triggers. The fix should be fairly trivial - just handle this case. I can patch it up.

@mraleph mraleph self-assigned this Sep 11, 2023
@mraleph mraleph added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Sep 11, 2023
@mraleph mraleph removed the legacy-area-front-end Legacy: Use area-dart-model instead. label Sep 11, 2023
@RickZzDev
Copy link

In my case i was having this problem using for each to desserialize a json response that was inside a list, when a change it to a "for in" it stopped to crash

@burekas7
Copy link
Author

burekas7 commented Sep 14, 2023

Does anyone know if this bug was fixed?
Because I see this issue is closed.

Should I need to update the dart sdk version?

@mraleph @johnniwinther

@johnniwinther
Copy link
Member

The issue has been fixed in the Dart repository and is available in the lastest dev release. It will be in the the next beta and stable releases.

@shawnAshton
Copy link

shawnAshton commented Oct 2, 2023

@johnniwinther I see you said this 3 weeks ago, so I made sure to update to new flutter & dart versions released after your comment.

(@mraleph tagging you as you authored the fix 3 weeks ago)

I still experience this issue with these updates that were released sept 27th (about 2 weeks after your comment).
flutter: 3.13.6
dart: 3.1.3
environment: sdk: '>=3.1.3 <4.0.0'

Unhandled exception:
Invalid argument(s): Iterables do not have same length.
#0      MapBase._fillMapWithIterables (dart:collection/maps.dart:178:7)
#1      new LinkedHashMap.fromIterables (dart:collection/linked_hash_map.dart:246:13)
#2      Substitution.fromPairs (package:kernel/type_algebra.dart:263:13)
#3      InferenceVisitorBase.getGetterTypeForMemberTarget (package:front_end/src/fasta/type_inference/inference_visitor_base.dart:1465:35)
#5      InferenceVisitorImpl._computePropertyGet (package:front_end/src/fasta/type_inference/inference_visitor.dart:6663:36)
#4      InstanceAccessTarget.getGetterType (package:front_end/src/fasta/type_inference/object_access_target.dart:489:30)
#6      InferenceVisitorImpl.visitPropertyGet (package:front_end/src/fasta/type_inference/inference_visitor.dart:7672:61)
#7      PropertyGet.acceptInference (package:front_end/src/fasta/kernel/internal_ast.dart:2984:20)
#8      InferenceVisitorImpl._inferExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:257:27)
#9      InferenceVisitorImpl.inferExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:291:40)
#10     InferenceVisitorImpl.visitReturnStatement (package:front_end/src/fasta/type_inference/inference_visitor.dart:7894:11)
#11     ReturnStatement.accept (package:kernel/ast.dart:10127:43)

#12     InferenceVisitorImpl.inferStatement (package:front_end/src/fasta/type_inference/inference_visitor.dart:242:26)
#13     TypeInferrerImpl.inferFunctionBody (package:front_end/src/fasta/type_inference/type_inferrer.dart:198:17)
#14     BodyBuilder.parseSingleExpression (package:front_end/src/fasta/kernel/body_builder.dart:1780:62)
#15     SourceLoader.buildExpression (package:front_end/src/fasta/source/source_loader.dart:1320:21)
<asynchronous suspension>
#16     IncrementalCompiler.compileExpression.<anonymous closure> (package:front_end/src/fasta/incremental_compiler.dart:2033:39)
<asynchronous suspension>
#17     IncrementalCompiler.compileExpression (package:front_end/src/fasta/incremental_compiler.dart:1853:12)
<asynchronous suspension>
#18     FrontendCompiler.compileExpression (package:frontend_server/frontend_server.dart:981:28)
<asynchronous suspension>
#19     listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1452:11)
<asynchronous suspension>

@jensjoha
Copy link
Contributor

jensjoha commented Oct 3, 2023

It seems you're on flutter stable meaning you don't get the dev releases of dart.

@shawnAshton
Copy link

It seems you're on flutter stable meaning you don't get the dev releases of dart.

As was mentioned above, It will be in the the next beta and stable releases.. I do see that that doesn't specify which next stable release though...

@mraleph
Copy link
Member

mraleph commented Oct 3, 2023

@shawnAshton next stable release means Dart 3.2.

@kashiflab
Copy link

It seems you're on flutter stable meaning you don't get the dev releases of dart.

As was mentioned above, It will be in the next beta and stable releases.. I do see that that doesn't specify which next stable release though...

@shawnAshton @mraleph Please push the latest release on the stable branch. I am stuck nothing is working, my timelines are disturbed because of this error.

@burekas7
Copy link
Author

burekas7 commented Nov 13, 2023

@kashiflab
Agree.
It is completely difficult to debug api calls like this,
I put a breakpoint and a few seconds later it crashes the application and debug.

When the stable release with the fix will be ready for use?
@mraleph @johnniwinther

@mraleph
Copy link
Member

mraleph commented Nov 14, 2023

Stable release is in the final rounds of testing and preparations for release. You could switch to Flutter beta channel if you want the fix already today.

@gabrielgiovans
Copy link

I bring good news guys, today I was looking for the problem and came across this topic.
The new version of flutter (3.16.0) released yesterday has fixed the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

13 participants