{"action":"created","issue":{"url":"https://api.github.com/repos/riscv/riscv-gcc/issues/19","repository_url":"https://api.github.com/repos/riscv/riscv-gcc","labels_url":"https://api.github.com/repos/riscv/riscv-gcc/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/riscv/riscv-gcc/issues/19/comments","events_url":"https://api.github.com/repos/riscv/riscv-gcc/issues/19/events","html_url":"https://github.com/riscv/riscv-gcc/issues/19","id":187009600,"number":19,"title":"Segfault when execution for tls test","user":{"login":"kito-cheng","id":2723185,"avatar_url":"https://avatars.githubusercontent.com/u/2723185?v=3","gravatar_id":"","url":"https://api.github.com/users/kito-cheng","html_url":"https://github.com/kito-cheng","followers_url":"https://api.github.com/users/kito-cheng/followers","following_url":"https://api.github.com/users/kito-cheng/following{/other_user}","gists_url":"https://api.github.com/users/kito-cheng/gists{/gist_id}","starred_url":"https://api.github.com/users/kito-cheng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kito-cheng/subscriptions","organizations_url":"https://api.github.com/users/kito-cheng/orgs","repos_url":"https://api.github.com/users/kito-cheng/repos","events_url":"https://api.github.com/users/kito-cheng/events{/privacy}","received_events_url":"https://api.github.com/users/kito-cheng/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"aswaterman","id":1031106,"avatar_url":"https://avatars.githubusercontent.com/u/1031106?v=3","gravatar_id":"","url":"https://api.github.com/users/aswaterman","html_url":"https://github.com/aswaterman","followers_url":"https://api.github.com/users/aswaterman/followers","following_url":"https://api.github.com/users/aswaterman/following{/other_user}","gists_url":"https://api.github.com/users/aswaterman/gists{/gist_id}","starred_url":"https://api.github.com/users/aswaterman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aswaterman/subscriptions","organizations_url":"https://api.github.com/users/aswaterman/orgs","repos_url":"https://api.github.com/users/aswaterman/repos","events_url":"https://api.github.com/users/aswaterman/events{/privacy}","received_events_url":"https://api.github.com/users/aswaterman/received_events","type":"User","site_admin":false},"assignees":[{"login":"aswaterman","id":1031106,"avatar_url":"https://avatars.githubusercontent.com/u/1031106?v=3","gravatar_id":"","url":"https://api.github.com/users/aswaterman","html_url":"https://github.com/aswaterman","followers_url":"https://api.github.com/users/aswaterman/followers","following_url":"https://api.github.com/users/aswaterman/following{/other_user}","gists_url":"https://api.github.com/users/aswaterman/gists{/gist_id}","starred_url":"https://api.github.com/users/aswaterman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aswaterman/subscriptions","organizations_url":"https://api.github.com/users/aswaterman/orgs","repos_url":"https://api.github.com/users/aswaterman/repos","events_url":"https://api.github.com/users/aswaterman/events{/privacy}","received_events_url":"https://api.github.com/users/aswaterman/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2016-11-03T09:25:49Z","updated_at":"2016-11-12T00:09:03Z","closed_at":null,"body":"Arch: RV32I, RV32G\r\nOption:  -pthread -O1\r\n\r\nHow to reproduce:\r\n\r\n```\r\n$ riscv32-unknown-linux-gnu-gcc tls-test.c  -pthread -O1\r\n$ qemu-riscv32 -L `riscv32-unknown-linux-gnu-gcc --print-sysroot` a.out\r\nSegmentation fault (core dumped)\r\n```\r\n\r\nCode for tls-test.c:\r\n```\r\n#include <pthread.h>\r\nextern int printf (char *,...);\r\n__thread int a = 5; \r\nint *volatile a_in_other_thread = (int *) 12345;\r\n\r\nstatic void *\r\nthread_func (void *arg)\r\n{\r\n  a_in_other_thread = &a;\r\n  a+=5;\r\n  *((int *) arg) = a;\r\n  return (void *)0;\r\n}\r\n\r\nint\r\nmain ()\r\n{\r\n  pthread_t thread;\r\n  void *thread_retval;\r\n\r\n  int *volatile a_in_main_thread;\r\n  int *volatile again ;\r\n  int thr_a;\r\n\r\n  a_in_main_thread = &a;\r\n\r\n  if (pthread_create (&thread, (pthread_attr_t *)0, thread_func, &thr_a))\r\n    return 0;\r\n\r\n  if (pthread_join (thread, &thread_retval))\r\n    return 0;\r\n\r\n  again = &a;\r\n  if (again != a_in_main_thread)\r\n    {\r\n      printf (\"FAIL: main thread addy changed from 0x%0x to 0x%0x\\n\", \r\n                a_in_other_thread, again);\r\n      return 1;\r\n    }\r\n\r\n  if (a != 5 || thr_a != 10 || (a_in_other_thread == a_in_main_thread))\r\n    {\r\n      printf (\"FAIL: a= %d, thr_a = %d Addr = 0x%0x\\n\", \r\n                a, thr_a, a_in_other_thread);\r\n      return 1;\r\n    }\r\n  return 0;\r\n}\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/riscv/riscv-gcc/issues/comments/260084534","html_url":"https://github.com/riscv/riscv-gcc/issues/19#issuecomment-260084534","issue_url":"https://api.github.com/repos/riscv/riscv-gcc/issues/19","id":260084534,"user":{"login":"aswaterman","id":1031106,"avatar_url":"https://avatars.githubusercontent.com/u/1031106?v=3","gravatar_id":"","url":"https://api.github.com/users/aswaterman","html_url":"https://github.com/aswaterman","followers_url":"https://api.github.com/users/aswaterman/followers","following_url":"https://api.github.com/users/aswaterman/following{/other_user}","gists_url":"https://api.github.com/users/aswaterman/gists{/gist_id}","starred_url":"https://api.github.com/users/aswaterman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aswaterman/subscriptions","organizations_url":"https://api.github.com/users/aswaterman/orgs","repos_url":"https://api.github.com/users/aswaterman/repos","events_url":"https://api.github.com/users/aswaterman/events{/privacy}","received_events_url":"https://api.github.com/users/aswaterman/received_events","type":"User","site_admin":false},"created_at":"2016-11-12T00:09:02Z","updated_at":"2016-11-12T00:09:02Z","body":"I think this is a duplicate of https://github.com/riscv/riscv-gnu-toolchain/issues/192 but I am working on it."}}
{"actor":{"display_login":"aswaterman"}}