{"action":"created","issue":{"url":"https://api.github.com/repos/xianyi/OpenBLAS/issues/1720","repository_url":"https://api.github.com/repos/xianyi/OpenBLAS","labels_url":"https://api.github.com/repos/xianyi/OpenBLAS/issues/1720/labels{/name}","comments_url":"https://api.github.com/repos/xianyi/OpenBLAS/issues/1720/comments","events_url":"https://api.github.com/repos/xianyi/OpenBLAS/issues/1720/events","html_url":"https://github.com/xianyi/OpenBLAS/issues/1720","id":348507965,"node_id":"MDU6SXNzdWUzNDg1MDc5NjU=","number":1720,"title":"GIMP hang / deadlock in get_memory_table / blas_thread_shutdown","user":{"login":"amurzeau","id":5435069,"node_id":"MDQ6VXNlcjU0MzUwNjk=","avatar_url":"https://avatars2.githubusercontent.com/u/5435069?v=4","gravatar_id":"","url":"https://api.github.com/users/amurzeau","html_url":"https://github.com/amurzeau","followers_url":"https://api.github.com/users/amurzeau/followers","following_url":"https://api.github.com/users/amurzeau/following{/other_user}","gists_url":"https://api.github.com/users/amurzeau/gists{/gist_id}","starred_url":"https://api.github.com/users/amurzeau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amurzeau/subscriptions","organizations_url":"https://api.github.com/users/amurzeau/orgs","repos_url":"https://api.github.com/users/amurzeau/repos","events_url":"https://api.github.com/users/amurzeau/events{/privacy}","received_events_url":"https://api.github.com/users/amurzeau/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":21,"created_at":"2018-08-07T22:21:02Z","updated_at":"2018-08-11T15:48:45Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nThere is a bug open in Debian related to gimp 2.10.2 and openblas 3.2: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=903514.\r\n\r\nDepending on the machine and environment used, gimp can deadlock at startup because of a deadlock inside glibc.\r\nI'm forwarding what I wrote for the Debian bug tracker:\r\n\r\nUsing gdb to find where it hung ([gimp-gdb.txt](https://gist.github.com/amurzeau/c0c1bae139388cb6656e471c7b90ac88)) gives threads waiting on\r\na lock while doing thread-local related stuff and the main thread is in\r\nthe process of dl_close-ing openblas waiting the threads to exit using\r\npthread_join.\r\n\r\nIt seems that the lock used in `tls_get_addr_tail` [0] is the same as\r\nthe one locked by `_dl_close` [1].\r\nA recursive lock is used but here it does not help as the thread calling\r\n`tls_get_addr_tail` and `_dl_close` are not the same.\r\n\r\nThis deadlock may not happen everytime, in my case, the openblas threads\r\nare still initializing while `_dl_close` is called.\r\n\r\nGiven this, I think the offending commit in openblas is bf40f806 [2]\r\nwhich add TLS variables to avoid locking. But many change were done\r\nsince then.\r\n\r\nOne of related bug report is [3] which seems to indicate that the locks\r\nhandling is not easy inside glibc.\r\n\r\nThere were an attempt to fix deadlocks between `tls_get_addr` and a\r\n`_dl_close` of a module whose finalizer joins with that thread [4].\r\n\r\nSo I see these possibles solutions:\r\n * Add a breaks between gimp and openblas\r\n * Disable TLS in openblas build (if possible, but this would cause a\r\nperformance loss for users that use openblas without gimp)\r\n * Patch glibc to not deadlock (but this seems not easy to do at all)\r\n\r\n[0] https://github.com/bminor/glibc/blob/glibc-2.27/elf/dl-tls.c#L761\r\n[1] https://github.com/bminor/glibc/blob/glibc-2.27/elf/dl-close.c#L812\r\n\r\n[2]\r\nhttps://github.com/xianyi/OpenBLAS/commit/bf40f806efa55c7a7c7ec57535919598eaeb569d#diff-31f8d4e8863583d95bf2f9529f83844e\r\n[4] https://sourceware.org/ml/libc-alpha/2015-06/msg00062.html"},"comment":{"url":"https://api.github.com/repos/xianyi/OpenBLAS/issues/comments/412283457","html_url":"https://github.com/xianyi/OpenBLAS/issues/1720#issuecomment-412283457","issue_url":"https://api.github.com/repos/xianyi/OpenBLAS/issues/1720","id":412283457,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMjI4MzQ1Nw==","user":{"login":"brada4","id":16061801,"node_id":"MDQ6VXNlcjE2MDYxODAx","avatar_url":"https://avatars3.githubusercontent.com/u/16061801?v=4","gravatar_id":"","url":"https://api.github.com/users/brada4","html_url":"https://github.com/brada4","followers_url":"https://api.github.com/users/brada4/followers","following_url":"https://api.github.com/users/brada4/following{/other_user}","gists_url":"https://api.github.com/users/brada4/gists{/gist_id}","starred_url":"https://api.github.com/users/brada4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brada4/subscriptions","organizations_url":"https://api.github.com/users/brada4/orgs","repos_url":"https://api.github.com/users/brada4/repos","events_url":"https://api.github.com/users/brada4/events{/privacy}","received_events_url":"https://api.github.com/users/brada4/received_events","type":"User","site_admin":false},"created_at":"2018-08-11T15:48:45Z","updated_at":"2018-08-11T15:48:45Z","author_association":"CONTRIBUTOR","body":"@amurzeau ok, packaging is correct. "}}
{"actor":{"display_login":"brada4"}}