-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vm/isolates] Ensure spawnUri'ed isolates keep their own origin_id.
Fixes #47674 TEST=send_object_to_spawn_uri_isolate_test.dart Change-Id: I96d81df5edbac3054220348be8654250246cad8b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220066 Reviewed-by: Siva Annamalai <[email protected]> Commit-Queue: Alexander Aprelev <[email protected]>
- Loading branch information
1 parent
6ae9f31
commit c4a07a8
Showing
4 changed files
with
114 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
runtime/tests/vm/dart/isolates/send_object_to_spawn_uri_isolate_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
// | ||
// This test ensures that one can't send user dart objects to | ||
// an isolate spawned via spawnUri. | ||
|
||
import 'dart:async'; | ||
import 'dart:io'; | ||
import 'dart:isolate'; | ||
|
||
import 'package:expect/expect.dart'; | ||
import "package:test/test.dart"; | ||
|
||
class Foo { | ||
var bar = 123; | ||
} | ||
|
||
Future<void> main(args, message) async { | ||
if (message == null) { | ||
final receivePort = ReceivePort(); | ||
final isolate = await Isolate.spawnUri( | ||
Platform.script, <String>[], <SendPort>[receivePort.sendPort], | ||
errorsAreFatal: true); | ||
final result = await receivePort.first; | ||
Expect.equals("done", result); | ||
return; | ||
} | ||
|
||
if (args.length > 0) { | ||
Expect.equals("worker", args[0]); | ||
final SendPort sendPort = message[0] as SendPort; | ||
Expect.throws(() => sendPort.send(Foo())); | ||
sendPort.send("done"); | ||
} else { | ||
final SendPort sendPort = message[0] as SendPort; | ||
|
||
final receivePort = ReceivePort(); | ||
try { | ||
final isolate = await Isolate.spawnUri( | ||
Platform.script, <String>["worker"], <SendPort>[receivePort.sendPort], | ||
errorsAreFatal: true); | ||
final result = await receivePort.first; | ||
Expect.equals("done", result); | ||
sendPort.send("done"); | ||
} catch (_) { | ||
sendPort.send("fail"); | ||
} | ||
|
||
sendPort.send("done"); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
runtime/tests/vm/dart_2/isolates/send_object_to_spawn_uri_isolate_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
// | ||
// @dart = 2.9 | ||
// | ||
// This test ensures that one can't send user dart objects to | ||
// an isolate spawned via spawnUri. | ||
|
||
import 'dart:async'; | ||
import 'dart:io'; | ||
import 'dart:isolate'; | ||
|
||
import 'package:expect/expect.dart'; | ||
import "package:test/test.dart"; | ||
|
||
class Foo { | ||
var bar = 123; | ||
} | ||
|
||
Future<void> main(args, message) async { | ||
if (message == null) { | ||
final receivePort = ReceivePort(); | ||
final isolate = await Isolate.spawnUri( | ||
Platform.script, <String>[], <SendPort>[receivePort.sendPort], | ||
errorsAreFatal: true); | ||
final result = await receivePort.first; | ||
Expect.equals("done", result); | ||
return; | ||
} | ||
|
||
if (args.length > 0) { | ||
Expect.equals("worker", args[0]); | ||
final SendPort sendPort = message[0] as SendPort; | ||
Expect.throws(() => sendPort.send(Foo())); | ||
sendPort.send("done"); | ||
} else { | ||
final SendPort sendPort = message[0] as SendPort; | ||
|
||
final receivePort = ReceivePort(); | ||
try { | ||
final isolate = await Isolate.spawnUri( | ||
Platform.script, <String>["worker"], <SendPort>[receivePort.sendPort], | ||
errorsAreFatal: true); | ||
final result = await receivePort.first; | ||
Expect.equals("done", result); | ||
sendPort.send("done"); | ||
} catch (_) { | ||
sendPort.send("fail"); | ||
} | ||
|
||
sendPort.send("done"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters