{"action":"created","issue":{"url":"https://api.github.com/repos/namhyung/uftrace/issues/725","repository_url":"https://api.github.com/repos/namhyung/uftrace","labels_url":"https://api.github.com/repos/namhyung/uftrace/issues/725/labels{/name}","comments_url":"https://api.github.com/repos/namhyung/uftrace/issues/725/comments","events_url":"https://api.github.com/repos/namhyung/uftrace/issues/725/events","html_url":"https://github.com/namhyung/uftrace/pull/725","id":432447381,"node_id":"MDExOlB1bGxSZXF1ZXN0MjY5OTE3MzU5","number":725,"title":"plthook: Skip dlsym to avoid infinite loop","user":{"login":"honggyukim","id":19642328,"node_id":"MDQ6VXNlcjE5NjQyMzI4","avatar_url":"https://avatars3.githubusercontent.com/u/19642328?v=4","gravatar_id":"","url":"https://api.github.com/users/honggyukim","html_url":"https://github.com/honggyukim","followers_url":"https://api.github.com/users/honggyukim/followers","following_url":"https://api.github.com/users/honggyukim/following{/other_user}","gists_url":"https://api.github.com/users/honggyukim/gists{/gist_id}","starred_url":"https://api.github.com/users/honggyukim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/honggyukim/subscriptions","organizations_url":"https://api.github.com/users/honggyukim/orgs","repos_url":"https://api.github.com/users/honggyukim/repos","events_url":"https://api.github.com/users/honggyukim/events{/privacy}","received_events_url":"https://api.github.com/users/honggyukim/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2019-04-12T08:27:34Z","updated_at":"2019-04-13T02:26:28Z","closed_at":null,"author_association":"COLLABORATOR","pull_request":{"url":"https://api.github.com/repos/namhyung/uftrace/pulls/725","html_url":"https://github.com/namhyung/uftrace/pull/725","diff_url":"https://github.com/namhyung/uftrace/pull/725.diff","patch_url":"https://github.com/namhyung/uftrace/pull/725.patch"},"body":"In some cases, it's tricky to avoid infinite loop if dlsym is hooked\r\nby libmcount.so.  Here is the problematic condition.\r\n\r\n1. dlsym is invoked in a library. Let's say \"libxxx.so\".\r\n2. dlsym is called to get the address of \"foo\". - dlsym(RTLD_NEXT, \"foo\")\r\n3. The actual implementation of \"foo\" is inside \"libfoo.so\".\r\n4. Inside the library \"libxxx.so\", \"foo\" is defined to override it.\r\n5. The execution sequence is \"foo@libxxx.so\", then \"foo@libfoo.so\".\r\n\r\nIf \"libmcount.so\" is preloaded in this case, it hooks \"foo@libxxx.so\"\r\nand executes \"dlsym\" instead of \"libxxx.so\".\r\n\r\nThe problem is that the return address of dlsym(RTLD_NEXT, \"foo\") is\r\nexpected the address of \"foo@libfoo.so\", but it returns \"foo@libxxx.so\".\r\n\r\nIf the subsequent call is made based on this return address, then\r\n\"foo@libxxx.so\" recursively calls itself and never finished.\r\n\r\nSince I don't have any better solution to make dlsym to find second next\r\n\"foo\" in the order of dynamic library list, this patch simply skips\r\ndlsym to avoid the such problem.\r\n\r\nThis problem is happened when --nest-libcall is used.\r\n\r\nFixed: #714\r\n\r\nSigned-off-by: Honggyu Kim <honggyu.kp@gmail.com>"},"comment":{"url":"https://api.github.com/repos/namhyung/uftrace/issues/comments/482768808","html_url":"https://github.com/namhyung/uftrace/pull/725#issuecomment-482768808","issue_url":"https://api.github.com/repos/namhyung/uftrace/issues/725","id":482768808,"node_id":"MDEyOklzc3VlQ29tbWVudDQ4Mjc2ODgwOA==","user":{"login":"honggyukim","id":19642328,"node_id":"MDQ6VXNlcjE5NjQyMzI4","avatar_url":"https://avatars3.githubusercontent.com/u/19642328?v=4","gravatar_id":"","url":"https://api.github.com/users/honggyukim","html_url":"https://github.com/honggyukim","followers_url":"https://api.github.com/users/honggyukim/followers","following_url":"https://api.github.com/users/honggyukim/following{/other_user}","gists_url":"https://api.github.com/users/honggyukim/gists{/gist_id}","starred_url":"https://api.github.com/users/honggyukim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/honggyukim/subscriptions","organizations_url":"https://api.github.com/users/honggyukim/orgs","repos_url":"https://api.github.com/users/honggyukim/repos","events_url":"https://api.github.com/users/honggyukim/events{/privacy}","received_events_url":"https://api.github.com/users/honggyukim/received_events","type":"User","site_admin":false},"created_at":"2019-04-13T02:26:28Z","updated_at":"2019-04-13T02:26:28Z","author_association":"COLLABORATOR","body":"The above simple example can reproduce the problem in x86_64."}}
{"actor":{"display_login":"honggyukim"}}