{"action":"created","issue":{"url":"https://api.github.com/repos/tmux/tmux/issues/14","labels_url":"https://api.github.com/repos/tmux/tmux/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/tmux/tmux/issues/14/comments","events_url":"https://api.github.com/repos/tmux/tmux/issues/14/events","html_url":"https://github.com/tmux/tmux/issues/14","id":85737270,"number":14,"title":"Tmux hangs when it runs out of file descriptors","user":{"login":"bruno-","id":1042682,"avatar_url":"https://avatars.githubusercontent.com/u/1042682?v=3","gravatar_id":"","url":"https://api.github.com/users/bruno-","html_url":"https://github.com/bruno-","followers_url":"https://api.github.com/users/bruno-/followers","following_url":"https://api.github.com/users/bruno-/following{/other_user}","gists_url":"https://api.github.com/users/bruno-/gists{/gist_id}","starred_url":"https://api.github.com/users/bruno-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bruno-/subscriptions","organizations_url":"https://api.github.com/users/bruno-/orgs","repos_url":"https://api.github.com/users/bruno-/repos","events_url":"https://api.github.com/users/bruno-/events{/privacy}","received_events_url":"https://api.github.com/users/bruno-/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-06-06T11:10:42Z","updated_at":"2015-07-01T13:17:11Z","closed_at":null,"body":"Hi,\r\nthis is a reply to the original issue 196 opened on sourceforge.\r\nThe problem was spotted on OSX where the default file descriptors limit is 256. When tmux used all the file descriptors, it would hang and the CPU would go to 100%.\r\n\r\nBelow is the copy/paste of the excerpts from the previous discussion.\r\n\r\n---\r\n\r\nI was able to reproduce the issue on Linux too. Here are steps to reproduce:\r\n\r\n- test machine: Ubuntu 14.04 cloud VPS with 512Mb ram\r\n- tmux -V is 2.0 (also tested on latest version from git, behaves the same)\r\n- the default output of ulimit -n command is 1024. To \"simulate\" OS X default limit, this was reduced to 256 with the following command: echo 'ulimit -n 256' | sudo tee -a /etc/profile, and the machine was restarted\r\n- tmux.conf:\r\n\r\n        set -g prefix C-a\r\n        set -g @success \"yep\"\r\n        set -g status-right 'Script #(ping -c 1 www.google.com >/dev/null 2>&1 && printf \"$(tmux show -gqv @success)\")'\r\n\r\n- start tmux\r\n- the ping command in status-right works ok, displays \"yep\"\r\n- use this command to create large number of windows `for i in $(seq 1 150); do tmux new-window; done`\r\n- there's no output from ping command now. At this point tmux starts using 100% CPU sometimes. By doing the next step that happens consistently.\r\n- In one of the panes run `tmux show -g status-right`. The command returns no output and at that moment tmux process CPU usage goes to 100% and never goes down. However, tmux stays responsive, windows can be changed and executing other commands works ok (which was not the case on OSX where things just freeze).\r\n\r\nEven with the above steps, Nicholas wasn't able to reproduce the issue. The suggestion was to try the following:\r\n\r\n> Can you go to server_accept_callback in server.c and comment out this line inside the if (ENFILE EMFILE) bit:\r\n> /* Delete and don't try again for 1 second. */\r\n> server_add_accept(1);\r\n\r\n---\r\n\r\nSo here's the update to this issue: unfortunately updating the above bit and recompiling didn't change anything. I can still get tmux to use 100% CPU consistently.\r\n\r\nIdea for moving forward on this: what do you think about using the linux server where reproducing the issue is easy? Would that help?\r\n\r\nI've created a linux server with everything set up (tmux installed, tmux.conf in place). Nicholas can ssh in with his [keys](https://github.com/nicm.keys) and Thomas with [his](https://github.com/ThomasAdam.keys). IP is: `46.101.186.232`. User is `root`. Tmux is cloned in `/root/src/tmux`. Feel free to do whatever you want on the server, I'll nuke it once we're done debugging.\r\n\r\nOnce again, steps to reproduce the issue consistently on the server:\r\n\r\n- start tmux\r\n- run `for i in $(seq 1 150); do tmux new-window; done`\r\n- in one of the panes run `tmux show -g status-right`\r\n- at this point `htop` should show tmux using 100% CPU\r\n\r\nI hope that will help!"},"comment":{"url":"https://api.github.com/repos/tmux/tmux/issues/comments/117667520","html_url":"https://github.com/tmux/tmux/issues/14#issuecomment-117667520","issue_url":"https://api.github.com/repos/tmux/tmux/issues/14","id":117667520,"user":{"login":"bruno-","id":1042682,"avatar_url":"https://avatars.githubusercontent.com/u/1042682?v=3","gravatar_id":"","url":"https://api.github.com/users/bruno-","html_url":"https://github.com/bruno-","followers_url":"https://api.github.com/users/bruno-/followers","following_url":"https://api.github.com/users/bruno-/following{/other_user}","gists_url":"https://api.github.com/users/bruno-/gists{/gist_id}","starred_url":"https://api.github.com/users/bruno-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bruno-/subscriptions","organizations_url":"https://api.github.com/users/bruno-/orgs","repos_url":"https://api.github.com/users/bruno-/repos","events_url":"https://api.github.com/users/bruno-/events{/privacy}","received_events_url":"https://api.github.com/users/bruno-/received_events","type":"User","site_admin":false},"created_at":"2015-07-01T13:17:11Z","updated_at":"2015-07-01T13:17:11Z","body":"Hi,\r\nthanks for the work on this issue so far and sorry for waiting so long for the response.\r\n\r\nI wasn't able to find `ktrace` program for OSX, but apparently there's `dtruss` - a `dtrace` script that is equivalent to `strace` tool on Linux. Here's the [link to `dtruss` program output](https://www.dropbox.com/s/5lvnr1qu1lf0g5q/tmux_high_cpu_osx_dtruss.txt.gz?dl=0) for tmux process when it's spinning on 100% CPU on OSX.\r\n\r\nAlso I managed to find a person that will give us access to OSX machine for free (as mentioned before, OSX servers aren't that cheap, they are in the range of ~US$ 50/month).\r\nI got SSH access to this server via OpenVPN and managed to reproduce tmux issue there.\r\n\r\nThomas, Nicholas are you interested in getting access to this OSX server?\r\nI think \"direct\" debugging will speed things up. Also this person is willing to give long term access for the needs of tmux project.\r\nIf you think this is a good idea, I'll email you directly so we can setup OpenVPN + ssh access for you.\r\n\r\nThanks"}}