Skip to content

vm: Bogus ConcurrentModificationError on _GrowableList.addAll #42011

@rakudrama

Description

@rakudrama

This program crashes on VM but not other platforms:

main() {
  var a = [];
  a.addAll(a);
}

Crash:

Unhandled exception:
Concurrent modification during iteration: Instance(length:0) of '_GrowableList'.
#0      List.addAll (dart:core-patch/growable_array.dart:191:11)
#1      main (file://bug1b5g.dart:3:5)
#2      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19)

DDC and dart2js only check for an unexpected length just after obtaining the element provided by the iterator.

This works on the VM which indicates that the _GrowableList.addAll(_GrowableList) path is incorrectly specialized:

import 'dart:collection';
main() {
  var a = [];
  a.addAll(UnmodifiableListView(a));
}

Metadata

Metadata

Assignees

Labels

area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-core

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions