Skip to content

Fix ThreadNameDoesNotAffectProcessName for Mono #35908

Description

@lambdageek

See #34064

We need a check in mono_native_thread_set_name on Linux that the tid does not represent the main thread of the program (in the sense that on Linux gettid () == getpid () for the main thread).

The problem is that mono_native_thread_set_name gets a MonoNativeThreadId (which is pthread_t on Linux) and we need to compare that to the OS thread id of the main thread (which is a pid_t - gettid () of the main thread is the same as getpid()).

We have mono_native_thread_os_id_get () but it only returns the pid_t of the current thread - not of an arbitrary MonoNativeThreadId.

So we need some mechanism to go from a MonoNativeThreadId (or maybe a MonoThreadInfo) to a native OS thread id.

Activity

  1. removed
    untriagedNew issue has not been triaged by the area owner
    on May 6, 2020
  2. self-assigned this
    on May 6, 2020
  3. lambdageek commented on May 6, 2020

    @lambdageek
    MemberAuthor

    We have MonoThreadInfo *mono_thread_info_lookup (MonoNativeThreadId tid) so one way to do this is to add a guint64 os_id field to MonoThreadInfo.

    The downside of mono_thread_info_lookup is it's a linear scan, which isn't great.

  4. lambdageek commented on May 7, 2020

    @lambdageek
    MemberAuthor

    Hm. Actually a faster way might just be to add a global "main thread" MonoNativeThreadId and set it in register_thread when we see getpid () == mono_native_thread_os_id_get ()

  5. ghost locked as resolved and limited conversation to collaborators on Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions