diff options
author | Andreas Gampe <agampe@google.com> | 2016-04-11 08:42:26 -0700 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2016-04-12 13:42:43 -0700 |
commit | 415d8070e37c20dfb7e6dc37e74fdb5fffc2022e (patch) | |
tree | 0d113b28219feacfc5c5af88b1f2123b2d3531a9 /runtime/native/java_lang_Thread.cc | |
parent | 8ace610a222892f7b700e4f95e50fa6315ab85c0 (diff) |
ART: Flag to fail thread creation
Add a flag to mark when the zygote is not allowed to create threads.
Bug: 27248115
Bug: 28149511
Change-Id: I1dc3620d9e7d0054c672b993d89459fc4b353dfc
Diffstat (limited to 'runtime/native/java_lang_Thread.cc')
-rw-r--r-- | runtime/native/java_lang_Thread.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/runtime/native/java_lang_Thread.cc b/runtime/native/java_lang_Thread.cc index 13edd67b5b..a742e812f7 100644 --- a/runtime/native/java_lang_Thread.cc +++ b/runtime/native/java_lang_Thread.cc @@ -47,6 +47,15 @@ static jboolean Thread_isInterrupted(JNIEnv* env, jobject java_thread) { static void Thread_nativeCreate(JNIEnv* env, jclass, jobject java_thread, jlong stack_size, jboolean daemon) { + // There are sections in the zygote that forbid thread creation. + Runtime* runtime = Runtime::Current(); + if (runtime->IsZygote() && runtime->IsZygoteNoThreadSection()) { + jclass internal_error = env->FindClass("java/lang/InternalError"); + CHECK(internal_error != nullptr); + env->ThrowNew(internal_error, "Cannot create threads in zygote"); + return; + } + Thread::CreateNativeThread(env, java_thread, stack_size, daemon == JNI_TRUE); } |