{"action":"created","comment":{"url":"https://api.github.com/repos/frida/frida-gum/pulls/comments/60206176","id":60206176,"diff_hunk":"@@ -0,0 +1,214 @@\n+/*\n+ * Copyright (C) 2015 Ole André Vadla Ravnås <oleavr@nowsecure.com>\n+ *\n+ * Licence: wxWindows Library Licence, Version 3.1\n+ */\n+\n+#include \"guminterceptor.h\"\n+#include \"gumprocess.h\"\n+#include \"gumspinlock.h\"\n+#include \"gumtls.h\"\n+\n+#include <pthread.h>\n+#include <string.h>\n+#include <sys/syspage.h>\n+\n+#define MAX_TMP_TLS_KEYS 5\n+\n+typedef struct _GumTmpTlsKey GumTmpTlsKey;\n+\n+struct _GumTmpTlsKey\n+{\n+  GumThreadId tid;\n+  GumTlsKey key;\n+  gpointer value;\n+};\n+\n+static GumTmpTlsKey _gum_tls_tmp_keys[MAX_TMP_TLS_KEYS];\n+static GumSpinlock _gum_tls_tmp_keys_lock;\n+\n+static gboolean _gum_tls_key_get_tmp_value (GumTlsKey key, gpointer* value);\n+static void _gum_tls_key_set_tmp_value (GumTlsKey key, gpointer value);\n+static void _gum_tls_key_delete_tmp_value (GumTlsKey key);\n+static void* _gum_tls_replacement_pthread_getspecific (pthread_key_t key);\n+static int _gum_tls_replacement_pthread_setspecific (pthread_key_t key, const void* value);\n+\n+void\n+_gum_tls_init (void)\n+{\n+  gum_spinlock_init (&_gum_tls_tmp_keys_lock);\n+  memset (_gum_tls_tmp_keys, 0, sizeof (_gum_tls_tmp_keys));\n+}\n+\n+void\n+_gum_tls_late_init (void)\n+{\n+  GumInterceptor* interceptor = gum_interceptor_obtain ();\n+\n+  gum_interceptor_begin_transaction (interceptor);\n+\n+  gum_interceptor_replace_function (interceptor, pthread_setspecific, _gum_tls_replacement_pthread_setspecific, NULL);\n+  gum_interceptor_replace_function (interceptor, pthread_getspecific, _gum_tls_replacement_pthread_getspecific, NULL);\n+\n+  gum_interceptor_end_transaction (interceptor);\n+}\n+\n+void\n+_gum_tls_deinit (void)\n+{\n+  GumInterceptor* interceptor = gum_interceptor_obtain ();\n+\n+  gum_interceptor_begin_transaction (interceptor);\n+\n+  gum_interceptor_revert_function (interceptor, pthread_getspecific);\n+  gum_interceptor_revert_function (interceptor, pthread_setspecific);\n+\n+  gum_interceptor_end_transaction (interceptor);\n+}\n+\n+\n+GumTlsKey\n+gum_tls_key_new (void)\n+{\n+  pthread_key_t key;\n+  gint res;\n+\n+  res = pthread_key_create (&key, NULL);\n+  g_assert_cmpint (res, ==, 0);\n+\n+  return key;\n+}\n+\n+void\n+gum_tls_key_free (GumTlsKey key)\n+{\n+  pthread_key_delete (key);\n+}\n+\n+gpointer\n+gum_tls_key_get_value (GumTlsKey key)\n+{\n+  gpointer value = NULL;\n+  if(_gum_tls_key_get_tmp_value (key, &value) == FALSE)","path":"gum/backend-qnx/gumtls-qnx.c","position":92,"original_position":92,"commit_id":"14c83109cc3a24138b0466b89e6557a4b60bedf9","original_commit_id":"14c83109cc3a24138b0466b89e6557a4b60bedf9","user":{"login":"oleavr","id":735197,"avatar_url":"https://avatars.githubusercontent.com/u/735197?v=3","gravatar_id":"","url":"https://api.github.com/users/oleavr","html_url":"https://github.com/oleavr","followers_url":"https://api.github.com/users/oleavr/followers","following_url":"https://api.github.com/users/oleavr/following{/other_user}","gists_url":"https://api.github.com/users/oleavr/gists{/gist_id}","starred_url":"https://api.github.com/users/oleavr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oleavr/subscriptions","organizations_url":"https://api.github.com/users/oleavr/orgs","repos_url":"https://api.github.com/users/oleavr/repos","events_url":"https://api.github.com/users/oleavr/events{/privacy}","received_events_url":"https://api.github.com/users/oleavr/received_events","type":"User","site_admin":false},"body":"`if(` is missing a space.","created_at":"2016-04-19T10:18:37Z","updated_at":"2016-04-19T10:18:37Z","html_url":"https://github.com/frida/frida-gum/pull/157#discussion_r60206176","pull_request_url":"https://api.github.com/repos/frida/frida-gum/pulls/157","_links":{"self":{"href":"https://api.github.com/repos/frida/frida-gum/pulls/comments/60206176"},"html":{"href":"https://github.com/frida/frida-gum/pull/157#discussion_r60206176"},"pull_request":{"href":"https://api.github.com/repos/frida/frida-gum/pulls/157"}}},"pull_request":{"url":"https://api.github.com/repos/frida/frida-gum/pulls/157","id":64799669,"html_url":"https://github.com/frida/frida-gum/pull/157","diff_url":"https://github.com/frida/frida-gum/pull/157.diff","patch_url":"https://github.com/frida/frida-gum/pull/157.patch","issue_url":"https://api.github.com/repos/frida/frida-gum/issues/157","number":157,"state":"open","locked":false,"title":"Implement temporary 'TLS' storage to work around malloc being called by pthread_setspecific","user":{"login":"s1341","id":5682183,"avatar_url":"https://avatars.githubusercontent.com/u/5682183?v=3","gravatar_id":"","url":"https://api.github.com/users/s1341","html_url":"https://github.com/s1341","followers_url":"https://api.github.com/users/s1341/followers","following_url":"https://api.github.com/users/s1341/following{/other_user}","gists_url":"https://api.github.com/users/s1341/gists{/gist_id}","starred_url":"https://api.github.com/users/s1341/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s1341/subscriptions","organizations_url":"https://api.github.com/users/s1341/orgs","repos_url":"https://api.github.com/users/s1341/repos","events_url":"https://api.github.com/users/s1341/events{/privacy}","received_events_url":"https://api.github.com/users/s1341/received_events","type":"User","site_admin":false},"body":"…in pthread_setspecific","created_at":"2016-03-31T14:30:00Z","updated_at":"2016-04-19T10:18:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"777bbdab1b8d1683bb9c374305e94bda448091e7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/frida/frida-gum/pulls/157/commits","review_comments_url":"https://api.github.com/repos/frida/frida-gum/pulls/157/comments","review_comment_url":"https://api.github.com/repos/frida/frida-gum/pulls/comments{/number}","comments_url":"https://api.github.com/repos/frida/frida-gum/issues/157/comments","statuses_url":"https://api.github.com/repos/frida/frida-gum/statuses/14c83109cc3a24138b0466b89e6557a4b60bedf9","head":{"label":"s1341:master","ref":"master","sha":"14c83109cc3a24138b0466b89e6557a4b60bedf9","user":{"login":"s1341","id":5682183,"avatar_url":"https://avatars.githubusercontent.com/u/5682183?v=3","gravatar_id":"","url":"https://api.github.com/users/s1341","html_url":"https://github.com/s1341","followers_url":"https://api.github.com/users/s1341/followers","following_url":"https://api.github.com/users/s1341/following{/other_user}","gists_url":"https://api.github.com/users/s1341/gists{/gist_id}","starred_url":"https://api.github.com/users/s1341/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s1341/subscriptions","organizations_url":"https://api.github.com/users/s1341/orgs","repos_url":"https://api.github.com/users/s1341/repos","events_url":"https://api.github.com/users/s1341/events{/privacy}","received_events_url":"https://api.github.com/users/s1341/received_events","type":"User","site_admin":false},"repo":{"id":48430626,"name":"frida-gum","full_name":"s1341/frida-gum","owner":{"login":"s1341","id":5682183,"avatar_url":"https://avatars.githubusercontent.com/u/5682183?v=3","gravatar_id":"","url":"https://api.github.com/users/s1341","html_url":"https://github.com/s1341","followers_url":"https://api.github.com/users/s1341/followers","following_url":"https://api.github.com/users/s1341/following{/other_user}","gists_url":"https://api.github.com/users/s1341/gists{/gist_id}","starred_url":"https://api.github.com/users/s1341/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s1341/subscriptions","organizations_url":"https://api.github.com/users/s1341/orgs","repos_url":"https://api.github.com/users/s1341/repos","events_url":"https://api.github.com/users/s1341/events{/privacy}","received_events_url":"https://api.github.com/users/s1341/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/s1341/frida-gum","description":"Low-level code instrumentation library used by frida-core","fork":true,"url":"https://api.github.com/repos/s1341/frida-gum","forks_url":"https://api.github.com/repos/s1341/frida-gum/forks","keys_url":"https://api.github.com/repos/s1341/frida-gum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/s1341/frida-gum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/s1341/frida-gum/teams","hooks_url":"https://api.github.com/repos/s1341/frida-gum/hooks","issue_events_url":"https://api.github.com/repos/s1341/frida-gum/issues/events{/number}","events_url":"https://api.github.com/repos/s1341/frida-gum/events","assignees_url":"https://api.github.com/repos/s1341/frida-gum/assignees{/user}","branches_url":"https://api.github.com/repos/s1341/frida-gum/branches{/branch}","tags_url":"https://api.github.com/repos/s1341/frida-gum/tags","blobs_url":"https://api.github.com/repos/s1341/frida-gum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/s1341/frida-gum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/s1341/frida-gum/git/refs{/sha}","trees_url":"https://api.github.com/repos/s1341/frida-gum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/s1341/frida-gum/statuses/{sha}","languages_url":"https://api.github.com/repos/s1341/frida-gum/languages","stargazers_url":"https://api.github.com/repos/s1341/frida-gum/stargazers","contributors_url":"https://api.github.com/repos/s1341/frida-gum/contributors","subscribers_url":"https://api.github.com/repos/s1341/frida-gum/subscribers","subscription_url":"https://api.github.com/repos/s1341/frida-gum/subscription","commits_url":"https://api.github.com/repos/s1341/frida-gum/commits{/sha}","git_commits_url":"https://api.github.com/repos/s1341/frida-gum/git/commits{/sha}","comments_url":"https://api.github.com/repos/s1341/frida-gum/comments{/number}","issue_comment_url":"https://api.github.com/repos/s1341/frida-gum/issues/comments{/number}","contents_url":"https://api.github.com/repos/s1341/frida-gum/contents/{+path}","compare_url":"https://api.github.com/repos/s1341/frida-gum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/s1341/frida-gum/merges","archive_url":"https://api.github.com/repos/s1341/frida-gum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/s1341/frida-gum/downloads","issues_url":"https://api.github.com/repos/s1341/frida-gum/issues{/number}","pulls_url":"https://api.github.com/repos/s1341/frida-gum/pulls{/number}","milestones_url":"https://api.github.com/repos/s1341/frida-gum/milestones{/number}","notifications_url":"https://api.github.com/repos/s1341/frida-gum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/s1341/frida-gum/labels{/name}","releases_url":"https://api.github.com/repos/s1341/frida-gum/releases{/id}","deployments_url":"https://api.github.com/repos/s1341/frida-gum/deployments","created_at":"2015-12-22T12:25:29Z","updated_at":"2016-01-11T12:23:43Z","pushed_at":"2016-04-13T15:36:15Z","git_url":"git://github.com/s1341/frida-gum.git","ssh_url":"git@github.com:s1341/frida-gum.git","clone_url":"https://github.com/s1341/frida-gum.git","svn_url":"https://github.com/s1341/frida-gum","homepage":"","size":13638,"stargazers_count":1,"watchers_count":1,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"frida:master","ref":"master","sha":"12fa177ef1f79194f7fefbecc2f1f779a52e2b8b","user":{"login":"frida","id":4073090,"avatar_url":"https://avatars.githubusercontent.com/u/4073090?v=3","gravatar_id":"","url":"https://api.github.com/users/frida","html_url":"https://github.com/frida","followers_url":"https://api.github.com/users/frida/followers","following_url":"https://api.github.com/users/frida/following{/other_user}","gists_url":"https://api.github.com/users/frida/gists{/gist_id}","starred_url":"https://api.github.com/users/frida/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frida/subscriptions","organizations_url":"https://api.github.com/users/frida/orgs","repos_url":"https://api.github.com/users/frida/repos","events_url":"https://api.github.com/users/frida/events{/privacy}","received_events_url":"https://api.github.com/users/frida/received_events","type":"Organization","site_admin":false},"repo":{"id":9340574,"name":"frida-gum","full_name":"frida/frida-gum","owner":{"login":"frida","id":4073090,"avatar_url":"https://avatars.githubusercontent.com/u/4073090?v=3","gravatar_id":"","url":"https://api.github.com/users/frida","html_url":"https://github.com/frida","followers_url":"https://api.github.com/users/frida/followers","following_url":"https://api.github.com/users/frida/following{/other_user}","gists_url":"https://api.github.com/users/frida/gists{/gist_id}","starred_url":"https://api.github.com/users/frida/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frida/subscriptions","organizations_url":"https://api.github.com/users/frida/orgs","repos_url":"https://api.github.com/users/frida/repos","events_url":"https://api.github.com/users/frida/events{/privacy}","received_events_url":"https://api.github.com/users/frida/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/frida/frida-gum","description":"Low-level code instrumentation library used by frida-core","fork":false,"url":"https://api.github.com/repos/frida/frida-gum","forks_url":"https://api.github.com/repos/frida/frida-gum/forks","keys_url":"https://api.github.com/repos/frida/frida-gum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/frida/frida-gum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/frida/frida-gum/teams","hooks_url":"https://api.github.com/repos/frida/frida-gum/hooks","issue_events_url":"https://api.github.com/repos/frida/frida-gum/issues/events{/number}","events_url":"https://api.github.com/repos/frida/frida-gum/events","assignees_url":"https://api.github.com/repos/frida/frida-gum/assignees{/user}","branches_url":"https://api.github.com/repos/frida/frida-gum/branches{/branch}","tags_url":"https://api.github.com/repos/frida/frida-gum/tags","blobs_url":"https://api.github.com/repos/frida/frida-gum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/frida/frida-gum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/frida/frida-gum/git/refs{/sha}","trees_url":"https://api.github.com/repos/frida/frida-gum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/frida/frida-gum/statuses/{sha}","languages_url":"https://api.github.com/repos/frida/frida-gum/languages","stargazers_url":"https://api.github.com/repos/frida/frida-gum/stargazers","contributors_url":"https://api.github.com/repos/frida/frida-gum/contributors","subscribers_url":"https://api.github.com/repos/frida/frida-gum/subscribers","subscription_url":"https://api.github.com/repos/frida/frida-gum/subscription","commits_url":"https://api.github.com/repos/frida/frida-gum/commits{/sha}","git_commits_url":"https://api.github.com/repos/frida/frida-gum/git/commits{/sha}","comments_url":"https://api.github.com/repos/frida/frida-gum/comments{/number}","issue_comment_url":"https://api.github.com/repos/frida/frida-gum/issues/comments{/number}","contents_url":"https://api.github.com/repos/frida/frida-gum/contents/{+path}","compare_url":"https://api.github.com/repos/frida/frida-gum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/frida/frida-gum/merges","archive_url":"https://api.github.com/repos/frida/frida-gum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/frida/frida-gum/downloads","issues_url":"https://api.github.com/repos/frida/frida-gum/issues{/number}","pulls_url":"https://api.github.com/repos/frida/frida-gum/pulls{/number}","milestones_url":"https://api.github.com/repos/frida/frida-gum/milestones{/number}","notifications_url":"https://api.github.com/repos/frida/frida-gum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/frida/frida-gum/labels{/name}","releases_url":"https://api.github.com/repos/frida/frida-gum/releases{/id}","deployments_url":"https://api.github.com/repos/frida/frida-gum/deployments","created_at":"2013-04-10T07:25:56Z","updated_at":"2016-04-08T00:00:18Z","pushed_at":"2016-04-13T22:03:26Z","git_url":"git://github.com/frida/frida-gum.git","ssh_url":"git@github.com:frida/frida-gum.git","clone_url":"https://github.com/frida/frida-gum.git","svn_url":"https://github.com/frida/frida-gum","homepage":"","size":14708,"stargazers_count":61,"watchers_count":61,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":29,"forks":26,"open_issues":29,"watchers":61,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/frida/frida-gum/pulls/157"},"html":{"href":"https://github.com/frida/frida-gum/pull/157"},"issue":{"href":"https://api.github.com/repos/frida/frida-gum/issues/157"},"comments":{"href":"https://api.github.com/repos/frida/frida-gum/issues/157/comments"},"review_comments":{"href":"https://api.github.com/repos/frida/frida-gum/pulls/157/comments"},"review_comment":{"href":"https://api.github.com/repos/frida/frida-gum/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/frida/frida-gum/pulls/157/commits"},"statuses":{"href":"https://api.github.com/repos/frida/frida-gum/statuses/14c83109cc3a24138b0466b89e6557a4b60bedf9"}}}}