8000 Unable to handle lowercase thread state indicator on Linux · Issue #3 · frida/frida-gum · GitHub
[go: up one dir, main page]

Skip to content

Unable to handle lowercase thread state indicator on Linux #3

Closed

Description

@v-p-b

The following example code makes Frida crash with assertation error:

import frida

pid=frida.spawn("/bin/ls")
process = frida.attach(pid)
script = process.session.create_script("""
    Process.enumerateThreads({
      onMatch:function onMatch(thread){
        send("onMatch");
      },
      onComplete:function onComplete(){
        send("onComplete");
      }
    });
""")
script.load() # This is where we crash

Error message:

ERROR:../../../../frida-gum/gum/backend-linux/gumprocess-linux.c:658:gum_thread_state_from_proc_status_character: code should not be reached

System info:

$ uname -a
Linux buttercup 3.2.0-55-generic #85-Ubuntu SMP Wed Oct 2 12:29:27 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

The problem is that gum_thread_state_from_proc_status_character() is unable to handle tracing-stop state of a thread if it is indicated in lowercase ('t').

Source code:

static GumThreadState
gum_thread_state_from_proc_status_character (gchar c)
{
  switch (c)
  {
    case 'R': return GUM_THREAD_RUNNING;
    case 'S': return GUM_THREAD_WAITING;
    case 'D': return GUM_THREAD_UNINTERRUPTIBLE;
    case 'Z': return GUM_THREAD_UNINTERRUPTIBLE;
    case 'T': return GUM_THREAD_STOPPED;
    case 'W': return GUM_THREAD_UNINTERRUPTIBLE;
    default:
      g_assert_not_reached ();
      break;
  }
}

Thread info:

$ cat /proc/3529/task/3529/stat
3529 (ls) t 3527 3527 2965 34816 3527 4202496 241 0 0 0 0 0 0 0 20 0 9 0 80586 931430400 2631 18446744073709551615 4194304 4296076 140734664679936 140329654353208 4212132 0 0 16781440 1088 18446744071579355164 0 0 17 3 0 0 0 0 0
$ head -n 2 /proc/3529/task/3529/status 
Name:   ls
State:  t (tracing stop)

I don't know if using lowercase status indicator is normal, but looks like major distros work this way so a case conversion could probably help a lot of users.

Activity

  1. added a commit that references this issue on Feb 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0