Commit Graph

86 Commits

Author SHA1 Message Date
Zach Anderson 568b13905f [vm] Fixes for dartkb testing
The "vm" test suite is cauing the kernel bytecode compiler to
OOM on the bot, so this CL removes it from the test matrix for
dartkb. This CL also protects against non-utf8 data coming in
on the error message pipe during process spawning.

Change-Id: Iab110a49a49ea12d21037719716a228776343602
Reviewed-on: https://dart-review.googlesource.com/74490
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-09-12 20:02:10 +00:00
Zach Anderson 27c79f9459 [vm] Propagate more UTF8 conversion errors
Change-Id: I8d4f3a892a51bed8b922961bd74bcad727f66508
Reviewed-on: https://dart-review.googlesource.com/73280
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-09-06 02:23:21 +00:00
Zachary Anderson 6523896c6f [dart:io] Adds ProcessStartMode.INHERIT_STDIO
Adds a ProcessStartMode in which the child process inherits the stdio
handles from the parent.

Change-Id: Ibe7b8ae08caccaed827ae0a911a3cced7803cb6b
Reviewed-on: https://dart-review.googlesource.com/36362
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-01-23 22:50:06 +00:00
Alexander Markov c1212311bf [VM] Fix OOM handling when allocating buffers in dart:io
Reland 1d6c1020c9 with the fix for ASAN
bots.

* Test standalone_2/file_error_test is updated for Dart 2.0 fixed-size
  integers.

* This update revealed that certain dart:io native methods do not handle
  out-of-memory properly when I/O buffers are allocated.
  This CL fixes this bug.

* Updated test point is extracted to a separate test
  standalone_2/file_error2_test as it needs custom ASAN options.

Change-Id: Ifb1fa59828f36dc03d45c18a41d45da6b989d70a
Reviewed-on: https://dart-review.googlesource.com/20908
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2017-11-15 18:06:31 +00:00
Alexander Markov f28005819b Revert "[VM] Fix OOM handling when allocating buffers in dart:io"
This reverts commit 1d6c1020c9.

Reason: failures on ASAN bots as ASAN is not configured to
accept memory allocations with huge size.
Change-Id: Ibb3b27f60017fb42e0f36caea2262125f5bb40d0
Reviewed-on: https://dart-review.googlesource.com/20900
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2017-11-14 21:33:25 +00:00
Alexander Markov 1d6c1020c9 [VM] Fix OOM handling when allocating buffers in dart:io
* Test standalone_2/file_error_test is updated for Dart 2.0 fixed-size
  integers.

* This update revealed that certain dart:io native methods do not handle
  out-of-memory properly when I/O buffers are allocated.
  This CL fixes this bug.

Change-Id: I6a9018ab86da7b163d9797d745544835dfb0f15c
Reviewed-on: https://dart-review.googlesource.com/20582
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2017-11-14 18:26:34 +00:00
Zachary Anderson 0951ab163b [dart:io] Don't use fexecve. It is weird.
fexecve overwrites argv[0] for cases in which the exec'd binary should
close the fd itself rather than the calling process. This makes it
inappropriate for use in the VM. Instead the VM should use
execveat, however it hasn't been added to the C Library everywhere,
yet.

fixes #30971

Change-Id: I82085f24ded2f0b846d9193ca55903686e1f3585
Reviewed-on: https://dart-review.googlesource.com/10205
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2017-10-03 20:15:03 +00:00
Zachary Anderson d0295c873c [dart:io] Namespaces for file IO
Fuchsia requires the ability to sandbox Isolates w.r.t. file IO.
When a new Isolate starts, Fuchsia will pass the Isolate an object
called a namespace. We can translate the namespace object into a
file descriptor suitable for passing to the *at() family of
POSIX file system calls. The file system calls will then
have visibility only into the specified namespace.

We also plumb Namespaces through on all the other platforms as well to
make the change easier to test and so that in the future we can
implement e.g. per-isolate cwds.

This change adds a new internal class to dart:io called _Namespace,
which is implemented in a patch file. See:

sdk/lib/io/namespace_impl.dart
runtime/bin/namespace_patch.dart

The embedder can set up a non-default namespace by calling
_Namespace._setupNamespace during Isolate setup.

Instances of _Namespace have a native field that holds a pointer
to a native Namespace object. See:

runtime/bin/namespace.h

Calls from e.g. file_impl.dart are now also passed a
_Namespace object. The implementations in e.g. file.cc and
file_linux.cc then extract the namespace, and use it to compute a
file descriptor and path suitable for passing to e.g. openat().

related US-313

R=asiva@google.com, rmacnak@google.com

Review-Url: https://codereview.chromium.org/3007703002 .
2017-08-30 09:34:36 -07:00
Zachary Anderson 747868f2b1 [dart:io] Remove DART_IO_DISABLED
This was only used by Dartium.

Review-Url: https://codereview.chromium.org/3009523002 .
2017-08-24 11:17:52 -07:00
Carlo Bernaschina 491390eeaa Refactor of the GetEmbedderInformation APIs
The embedder can rely on embedded_dart_io to partially fill the
Dart_EmbedderInformation structure with all the process related
information.

R=zra@google.com

Review-Url: https://codereview.chromium.org/2997013002 .
2017-08-16 10:59:27 -07:00
Zachary Anderson 6cd8a79078 VM: Re-format to use at most one newline between functions
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2974233002 .
2017-07-13 08:08:37 -07:00
Zachary Anderson 4ecf748d5e [dart:io] Fixes a crash in VM shutdown when signals are watched
This CL fixes a crash in VM shutdown which is triggered by Dart programs
that throw unhandled exceptions while watching OS signals.

fixes #30033

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2961993002 .
2017-06-28 11:05:07 -07:00
Zachary Anderson 9ce608e89d [dart:io] Adds ProcessInfo.{max,current}Rss. Adds OS::MaxRSS on Fuchsia.
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2822943002 .
2017-04-17 14:41:40 -07:00
Zachary Anderson 8c9c54d833 [dart:io] Don't close stdin with a socket finalizer
If an Isolate touches the 'stdio' getter, a _NativeSocket with
attached finalizer is created for it. Previously, when such an
Isolate exited, the finalizer would close the underlying
file descriptor. This CL changes the finalizer for stdin such
that the native objects will be cleaned up, but the underlying
file descriptor will not be closed. The underlying file
descriptor will now only be closed if the stdin stream
subscription is explicitly canceled.

Accessing the stdin getter after the stream is explicitly
canceled will result in a FileSystemException.

See also: https://github.com/dart-lang/test/issues/583

fixes #29229

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2791423002 .
2017-04-04 13:57:42 -07:00
Zachary Anderson 89dba57bcf [dart:io] Adds a finalizer to _NativeSocket to avoid socket leaks
The finalizer sends the "close" message to the EventHandler for the
file descriptor in the _NativeSocket's native field. To avoid races and
spurious messages, this CL stores a pointer to a wrapper object in the
native field instead of the file descriptor. All messsages about the
_NativeSocket sent to the EventHandler use the wrapper object instead of
the file descriptor. When the EventHandler closes the file, the file
descriptor in the wrapper object is set to -1 so that the finalizer will
instead do nothing.

On Windows, there is another level of indirection since the OS HANDLEs
were already wrapped in various kinds of Handle objects. As an additional
complication, ClientSocket close on Windows is asynchronous, so the
EventHandler may shutdown before all of the ClientSocket Handles can be
destroyed.

related #27898, #28081

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2760293002 .
2017-03-28 07:44:05 -07:00
Zachary Anderson 479a97b129 clang-format runtime/bin
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2480793002 .
2016-11-04 12:30:56 -07:00
Ryan Macnak 4d65db8a95 Don't use IsolateData for the exit hook as multiple embedders share the dart/bin while using different isolate data structures.
Issue flutter/flutter#6506

R=asiva@google.com

Review URL: https://codereview.chromium.org/2463923002 .
2016-10-31 15:56:25 -07:00
Ryan Macnak 5ee94eb837 Generate an app snapshot even if the training run does a hard exit.
(As the analyzer and pub do.)

R=asiva@google.com

Review URL: https://codereview.chromium.org/2426843002 .
2016-10-19 09:37:47 -07:00
Zachary Anderson 7308e58c3f Really remove io support when dart:io is unsupported.
Previously we would compile in implementaitions of native calls for
IO functions that would never be used. This CL provides implementations
that throw a Dart exception if they're called by mistake. It also uses
a DART_IO_DISABLED preprocessor define to clean up the build files and
check that we're not including code we shouldn't.

R=iposva@google.com, johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1839463002 .
2016-03-29 11:22:03 -07:00
Zachary Anderson 45661a7091 Cleanup in //runtime/bin
R=iposva@google.com

Review URL: https://codereview.chromium.org/1800863002 .
2016-03-16 10:01:00 -07:00
Zachary Anderson c75a817ee0 Fixes some memory leaks in //runtime/bin
Also some style cleanups.

Decided to fix these leaks by using Dart_ScopeAllocate
instead of malloc and new. Leaks are noted in the CL.

I haven't finished looking over all the code in
//runtime/bin yet, but this CL was getting big.

Review URL: https://codereview.chromium.org/1781883002 .
2016-03-14 11:08:52 -07:00
Todd Turnidge 4e3643f445 Prefer Dart_SetReturnValue over Dart_PropagateError when it makes sense.
BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1665993002 .
2016-02-03 15:41:54 -08:00
Ivan Posva 6249c2bcf3 - Remove the legacy debug protocol.
BUG=
R=hausner@google.com

Review URL: https://codereview.chromium.org/1497033003 .
2015-12-03 17:46:02 -08:00
Zachary Anderson 2c5044b671 Don't do clean shutdown on Process.exit()
BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1428923003 .
2015-11-03 14:10:42 -08:00
Zachary Anderson 3563dc0fb0 Use ExitProcess on Windows.
Even after joining threads, it is still possible for the exit code to be
polluted. NaCL uses ExitProcess to avoid this problem:

https://code.google.com/p/chromium/codesearch#chromium/src/native_client/src/shared/platform/win/nacl_exit.c

This change also cleans up thread local storage for the last Thread.

BUG=
R=iposva@google.com

Review URL: https://codereview.chromium.org/1410293006 .
2015-10-29 23:35:46 -07:00
John McCutchan 4b4e836960 Fix build breakage encountered by Flutter
BUG=

Review URL: https://codereview.chromium.org//1376143004 .
2015-10-01 07:18:27 -07:00
Zachary Anderson a580bafc5d Disable shutdown
BUG=

Review URL: https://codereview.chromium.org//1350713004 .
2015-09-16 15:51:10 -07:00
Zachary Anderson 7093f2996b VM thread shutdown.
BUG=
R=iposva@google.com, turnidge@google.com

Review URL: https://codereview.chromium.org//1275353005 .
2015-09-15 12:49:52 -07:00
Zachary Anderson 98384272a5 Don't stop the event handler.
The EventHandler can't be stopped until Dart_Cleanup shuts down all isolates and cleans up all VM thread pool threads.

TBR

BUG=

Review URL: https://codereview.chromium.org//1325963002 .
2015-09-01 20:33:38 -07:00
Zachary Anderson 9395a5b86f Join embedder threads on Windows.
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//1291163002 .
2015-09-01 17:53:03 -07:00
Zachary Anderson d4d89d6f12 Reverts VM thread cleanup
BUG=

Review URL: https://codereview.chromium.org//1275853008 .
2015-08-07 19:10:31 -07:00
Zachary Anderson 55bfb3d54b Clean VM thread shutdown:
Second attempt at: https://codereview.chromium.org/1177153005/

This time with fixed error propagation in the embedder.

R=turnidge@google.com

Review URL: https://codereview.chromium.org//1279733003 .
2015-08-07 18:42:00 -07:00
Zachary Anderson 4ca87e6d88 Revert VM thread cleanup
TBR

BUG=

Review URL: https://codereview.chromium.org//1270323002 .
2015-08-05 01:27:01 -07:00
Zachary Anderson 174d552574 Enables clean VM shutdown.
. Disables isolate spawning during Dart_Cleanup.
. Adds a static call Isolate::KillAllIsolates, which sends the
  OOB Kill message to all isolates when called from
  Dart_Cleanup.
. Modifies thread pool shutdown to block until all threads have
  exited.
. Fixes tests.

BUG=
R=turnidge@google.com

Review URL: https://codereview.chromium.org//1177153005 .
2015-08-04 23:29:25 -07:00
Soren Gjesse 0415d9271d Improve the encoding/decoding to/from system encoding on Windows
On Windows the dart:io SYSTEM_ENCODING is now also working with strings
which have null characters in them. Previously the string would be
terminated at the null character.

BUG=https://github.com/dart-lang/sdk/issues/23295
R=kustermann@google.com, lrn@google.com

Review URL: https://codereview.chromium.org//1194883002.
2015-06-24 10:36:05 +02:00
sgjesse@google.com 833e5d9aee Add support for killing a process with a given PID to dart:io
R=lrn@google.com, kustermann@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43455 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-04 08:20:33 +00:00
sgjesse@google.com 9aa4805e21 Add an option for starting a detached process with stdio connected
R=lrn@google.com, kustermann@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43393 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-03 13:38:38 +00:00
sgjesse@google.com 042462d69b Refactor the process creation code on POSIX platforms
This moved the process creation code to a class, and splits the
single function used before into several methods operation on instance
variables.

The refactor revealed at least one leaked file descriptor.

R=kustermann@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43280 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-29 13:06:40 +00:00
sgjesse@google.com f6a10fbdf1 Add support for starting a detached process
BUG=http://dartbug.com/20970
R=kustermann@google.com, lrn@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43070 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-22 11:49:39 +00:00
iposva@google.com 5a383e7add - Make sure that the threads for dart::bin are in the correct namespace.
R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39233 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-14 00:06:04 +00:00
johnmccutchan@google.com b3f2fb14d0 Reduce CPU usage when no isolates need to be profiled (e.g. when an isolate calls readLineSync or sleep the isolate owns the thread but is blocked).
This CL does the following:

- Introduces two new API entry points: Dart_IsolateBlocked and Dart_IsolateUnblocked.
- The thread interrupter thread goes into a deep sleep if no isolates need to be profiled (not scheduled on a thread or are in a blocking call).
- When an isolate unblocks, the thread interrupter thread resumes regular interrupts.
- dart:io readLineSync and sleep mark that they are making a blocking call.

This fixes https://code.google.com/p/dart/issues/detail?id=18126 reducing CPU usage to 0% when waiting for stdin or sleeping.

R=ajohnsen@google.com, iposva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36632 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-26 11:53:49 +00:00
ajohnsen@google.com 09a4f24413 Add exitCode getter counterpart to the existing setter in dart:io.
BUG=https://code.google.com/p/dart/issues/detail?id=16217
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33737 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-17 10:40:19 +00:00
ajohnsen@google.com 0f52be7f63 Make std* blocking file-descriptors.
This will most likely be a performance regression when piping, that
we'll have to look into in the future (copying data through
    message-passing).

BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32715 260f80e4-7a28-3924-810f-c04153c831b5
2014-02-17 10:06:35 +00:00
ajohnsen@google.com 38d0fad2c7 Signal handling, take 2.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31276 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-19 15:07:48 +00:00
ajohnsen@google.com f24f568571 Revert "Signal handling."
This reverts commit r31270.

BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31275 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-19 14:03:15 +00:00
ajohnsen@google.com e8d9794c70 Signal handling.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31270 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-19 13:08:26 +00:00
johnmccutchan@google.com 919dc2d6eb * Introduce ThreadInterrupter which calls a TLS set callback when thread is interrupted.
* Threads can only register and unregister themselves with ThreadInterrupter.
* Profiler is no longer involved in interrupting threads. It's just a callback and the buffer.
* Profiler operates lock free using an atomic operation to reserve sample in sample buffer.
* Linux, Mac, and Windows done.

R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31170 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-16 18:52:15 +00:00
sgjesse@google.com 72d2ca28c9 Cleanup the getting and setting of the socket file descriptor
R=ajohnsen@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@30524 260f80e4-7a28-3924-810f-c04153c831b5
2013-11-21 15:22:35 +00:00
ajohnsen@google.com b71e57617e Always mark stdout and stderr as blocking on exit.
This is required by some shell systems, such as Emacs.

BUG=https://code.google.com/p/dart/issues/detail?id=14301
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29895 260f80e4-7a28-3924-810f-c04153c831b5
2013-11-05 11:57:52 +00:00
sgjesse@google.com 264611807f Get rid of some downcasts
R=whesse@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26697 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-27 09:13:21 +00:00