{"action":"created","issue":{"url":"https://api.github.com/repos/iovisor/bcc/issues/415","repository_url":"https://api.github.com/repos/iovisor/bcc","labels_url":"https://api.github.com/repos/iovisor/bcc/issues/415/labels{/name}","comments_url":"https://api.github.com/repos/iovisor/bcc/issues/415/comments","events_url":"https://api.github.com/repos/iovisor/bcc/issues/415/events","html_url":"https://github.com/iovisor/bcc/pull/415","id":135654068,"number":415,"title":"funccount: use array map instead of hash","user":{"login":"4ast","id":12205493,"avatar_url":"https://avatars.githubusercontent.com/u/12205493?v=3","gravatar_id":"","url":"https://api.github.com/users/4ast","html_url":"https://github.com/4ast","followers_url":"https://api.github.com/users/4ast/followers","following_url":"https://api.github.com/users/4ast/following{/other_user}","gists_url":"https://api.github.com/users/4ast/gists{/gist_id}","starred_url":"https://api.github.com/users/4ast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/4ast/subscriptions","organizations_url":"https://api.github.com/users/4ast/orgs","repos_url":"https://api.github.com/users/4ast/repos","events_url":"https://api.github.com/users/4ast/events{/privacy}","received_events_url":"https://api.github.com/users/4ast/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2016-02-23T06:50:38Z","updated_at":"2016-02-23T20:43:05Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/iovisor/bcc/pulls/415","html_url":"https://github.com/iovisor/bcc/pull/415","diff_url":"https://github.com/iovisor/bcc/pull/415.diff","patch_url":"https://github.com/iovisor/bcc/pull/415.patch"},"body":"hash map is not safe when used in recursive context.\r\nIf kprobes are placed in the middle of memory allocator functions,\r\nthe recursive call of bpf_prog->map_update->kmalloc may crash.\r\nExample: funccount '*spin*' may dead lock the cpu.\r\nInstead use array map as a hash table.\r\nAfter the fix it works fine:\r\n$ sudo ./funccount.py '*spin*'\r\nTracing 33 functions for \"*spin*\"... Hit Ctrl-C to end.\r\n^C\r\nADDR             FUNC                          COUNT\r\nffffffff818dc121 _raw_spin_unlock_bh             779\r\nffffffff818dc461 _raw_spin_lock_bh              1359\r\nffffffff810990a1 mutex_spin_on_owner           11510\r\nffffffff818dc3f1 _raw_spin_trylock             14687\r\nffffffff810990f1 mutex_optimistic_spin         28618\r\nffffffff818dc2a1 _raw_spin_lock_irq            57933\r\nffffffff818dc211 _raw_spin_lock_irqsave       337914\r\nffffffff818dc0a1 __lock_text_start            360507\r\nffffffff818dc431 _raw_spin_lock               729764\r\nDetaching...\r\n\r\nSigned-off-by: Alexei Starovoitov <ast@fb.com>"},"comment":{"url":"https://api.github.com/repos/iovisor/bcc/issues/comments/187893457","html_url":"https://github.com/iovisor/bcc/pull/415#issuecomment-187893457","issue_url":"https://api.github.com/repos/iovisor/bcc/issues/415","id":187893457,"user":{"login":"brendangregg","id":1101211,"avatar_url":"https://avatars.githubusercontent.com/u/1101211?v=3","gravatar_id":"","url":"https://api.github.com/users/brendangregg","html_url":"https://github.com/brendangregg","followers_url":"https://api.github.com/users/brendangregg/followers","following_url":"https://api.github.com/users/brendangregg/following{/other_user}","gists_url":"https://api.github.com/users/brendangregg/gists{/gist_id}","starred_url":"https://api.github.com/users/brendangregg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendangregg/subscriptions","organizations_url":"https://api.github.com/users/brendangregg/orgs","repos_url":"https://api.github.com/users/brendangregg/repos","events_url":"https://api.github.com/users/brendangregg/events{/privacy}","received_events_url":"https://api.github.com/users/brendangregg/received_events","type":"User","site_admin":false},"created_at":"2016-02-23T20:43:05Z","updated_at":"2016-02-23T20:43:05Z","body":"More testing: it's just the counts.clear() that triggers the issue. It's not that funccount is exiting. This also hits it, after printing the first interval:\r\n\r\n```\r\n# ./funccount.py -i 1 '*spin*'\r\n```"}}