{"action":"opened","issue":{"url":"https://api.github.com/repos/Willtor/ThreadScan/issues/2","labels_url":"https://api.github.com/repos/Willtor/ThreadScan/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/Willtor/ThreadScan/issues/2/comments","events_url":"https://api.github.com/repos/Willtor/ThreadScan/issues/2/events","html_url":"https://github.com/Willtor/ThreadScan/issues/2","id":123583357,"number":2,"title":"Constructor ordering","user":{"login":"ndryden","id":1119788,"avatar_url":"https://avatars.githubusercontent.com/u/1119788?v=3","gravatar_id":"","url":"https://api.github.com/users/ndryden","html_url":"https://github.com/ndryden","followers_url":"https://api.github.com/users/ndryden/followers","following_url":"https://api.github.com/users/ndryden/following{/other_user}","gists_url":"https://api.github.com/users/ndryden/gists{/gist_id}","starred_url":"https://api.github.com/users/ndryden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ndryden/subscriptions","organizations_url":"https://api.github.com/users/ndryden/orgs","repos_url":"https://api.github.com/users/ndryden/repos","events_url":"https://api.github.com/users/ndryden/events{/privacy}","received_events_url":"https://api.github.com/users/ndryden/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-23T01:01:21Z","updated_at":"2015-12-23T01:01:21Z","closed_at":null,"body":"The methods `env_init` (in `env.c`) and `register_signal_handlers` (in `threadscan.c`) are both declared with `__attribute__((constructor))` with no priority given. Therefore, the order in which they run is not defined. However, `register_signal_handlers` requires the `g_threadscan_ptrs_per_thread` global variable to be properly initialized before it runs; this initialization is performed in `env_init`. If `register_signal_handlers` runs first, it initializes `g_tsdata` with garbage and everything is very unhappy.\r\n\r\nThe solution is to either have `register_signal_handlers` explicitly call `env_init` instead, or to give `env_init` a lower priority number (say 101) than `register_signal_handlers` (say 201)."}}