diff --git a/runtime/vm/os_thread_android.cc b/runtime/vm/os_thread_android.cc index b8354e744745..1d53af3036dc 100644 --- a/runtime/vm/os_thread_android.cc +++ b/runtime/vm/os_thread_android.cc @@ -8,7 +8,8 @@ #include "vm/os_thread.h" -#include // NOLINT +#include // NOLINT +#include #include // NOLINT #include "platform/address_sanitizer.h" @@ -119,8 +120,10 @@ static void* ThreadStart(void* data_ptr) { uword parameter = data->parameter(); delete data; - // Set the thread name. - pthread_setname_np(pthread_self(), name); + // Set the thread name. There is 16 bytes limit on the name (including \0). + char truncated_name[16]; + snprintf(truncated_name, ARRAY_SIZE(truncated_name), "%s", name); + pthread_setname_np(pthread_self(), truncated_name); // Create new OSThread object and set as TLS for new thread. OSThread* thread = OSThread::CreateOSThread(); diff --git a/runtime/vm/os_thread_linux.cc b/runtime/vm/os_thread_linux.cc index 0003ee257564..7622669444b9 100644 --- a/runtime/vm/os_thread_linux.cc +++ b/runtime/vm/os_thread_linux.cc @@ -8,7 +8,8 @@ #include "vm/os_thread.h" -#include // NOLINT +#include // NOLINT +#include #include // NOLINT #include // NOLINT #include // NOLINT @@ -121,8 +122,10 @@ static void* ThreadStart(void* data_ptr) { uword parameter = data->parameter(); delete data; - // Set the thread name. - pthread_setname_np(pthread_self(), name); + // Set the thread name. There is 16 bytes limit on the name (including \0). + char truncated_name[16]; + snprintf(truncated_name, ARRAY_SIZE(truncated_name), "%s", name); + pthread_setname_np(pthread_self(), truncated_name); // Create new OSThread object and set as TLS for new thread. OSThread* thread = OSThread::CreateOSThread(); diff --git a/runtime/vm/thread_pool.cc b/runtime/vm/thread_pool.cc index 8353648160bc..22f62ca5d115 100644 --- a/runtime/vm/thread_pool.cc +++ b/runtime/vm/thread_pool.cc @@ -335,7 +335,7 @@ void ThreadPool::Worker::StartThread() { ASSERT(task_ != nullptr); } #endif - int result = OSThread::Start("Dart ThreadPool Worker", &Worker::Main, + int result = OSThread::Start("DartWorker", &Worker::Main, reinterpret_cast(this)); if (result != 0) { FATAL1("Could not start worker thread: result = %d.", result);