Skip to content

[dart2js] List.insertAll can leave unsound null elements when interrupted #48134

Open
@askeksa-google

Description

@askeksa-google

Similarly to #48132, List.insertAll can leave null elements in a list with a non-nullable element type if the operation is interrupted by an exception:

import 'dart:collection';

class BadList extends ListBase<int> {
  int get length => 2;
  int operator [](int index) => throw "BOOM";

  set length(int l) => throw "unimplemented";
  void operator []=(int index, int value) => throw "unimplemented";
  void add(int e) => throw "unimplemented";
}

main() {
  List<int> list = [1, 2];
  try {
    list.insertAll(1, BadList());
  } catch (_) {}
  print(list.length);
  print(list[2]);
}

This prints either

4
null

or

4
undefined

depending on optimization level.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)web-dart2jsweb-triage-0repro is available

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions