{"action":"created","issue":{"url":"https://api.github.com/repos/tessel/t2-firmware/issues/30","labels_url":"https://api.github.com/repos/tessel/t2-firmware/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/tessel/t2-firmware/issues/30/comments","events_url":"https://api.github.com/repos/tessel/t2-firmware/issues/30/events","html_url":"https://github.com/tessel/t2-firmware/issues/30","id":75767964,"number":30,"title":"USB Daemon crashes with process responses larger than the max pipe buffer size","user":{"login":"johnnyman727","id":432909,"avatar_url":"https://avatars.githubusercontent.com/u/432909?v=3","gravatar_id":"","url":"https://api.github.com/users/johnnyman727","html_url":"https://github.com/johnnyman727","followers_url":"https://api.github.com/users/johnnyman727/followers","following_url":"https://api.github.com/users/johnnyman727/following{/other_user}","gists_url":"https://api.github.com/users/johnnyman727/gists{/gist_id}","starred_url":"https://api.github.com/users/johnnyman727/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnnyman727/subscriptions","organizations_url":"https://api.github.com/users/johnnyman727/orgs","repos_url":"https://api.github.com/users/johnnyman727/repos","events_url":"https://api.github.com/users/johnnyman727/events{/privacy}","received_events_url":"https://api.github.com/users/johnnyman727/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/tessel/t2-firmware/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":{"login":"johnnyman727","id":432909,"avatar_url":"https://avatars.githubusercontent.com/u/432909?v=3","gravatar_id":"","url":"https://api.github.com/users/johnnyman727","html_url":"https://github.com/johnnyman727","followers_url":"https://api.github.com/users/johnnyman727/followers","following_url":"https://api.github.com/users/johnnyman727/following{/other_user}","gists_url":"https://api.github.com/users/johnnyman727/gists{/gist_id}","starred_url":"https://api.github.com/users/johnnyman727/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnnyman727/subscriptions","organizations_url":"https://api.github.com/users/johnnyman727/orgs","repos_url":"https://api.github.com/users/johnnyman727/repos","events_url":"https://api.github.com/users/johnnyman727/events{/privacy}","received_events_url":"https://api.github.com/users/johnnyman727/received_events","type":"User","site_admin":false},"milestone":null,"comments":8,"created_at":"2015-05-12T22:49:21Z","updated_at":"2015-05-14T00:34:45Z","closed_at":null,"body":"I caught this error when I tried to retrieve details about what networks were around in a crowded space.\r\n\r\nEssentially, what happens is that the epoll indicates the child process has data on stdout to be read. All 4096 bytes are read from stdout into the internal buffer which causes [the `space_available` var to become 0 and it removes the child process file descriptor from epoll](https://github.com/tessel/t2-firmware/blob/master/soc/usbexecd.c#L524-L528). \r\n\r\nJust after reading the data from the process into the internal buf, we check and see if we can [write from the internal buffer to the CLI](https://github.com/tessel/t2-firmware/blob/master/soc/usbexecd.c#L532-L537). We then proceed to write it out to the CLI. Once all the data has been written to the USB connection, [we check if there is credit left on the pipe buffer](https://github.com/tessel/t2-firmware/blob/master/soc/usbexecd.c#L404-L407). There isn't, so we attempt to remove the pipe buffer from epoll again, which causes the crash. "},"comment":{"url":"https://api.github.com/repos/tessel/t2-firmware/issues/comments/101865374","html_url":"https://github.com/tessel/t2-firmware/issues/30#issuecomment-101865374","issue_url":"https://api.github.com/repos/tessel/t2-firmware/issues/30","id":101865374,"user":{"login":"kevinmehall","id":119951,"avatar_url":"https://avatars.githubusercontent.com/u/119951?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinmehall","html_url":"https://github.com/kevinmehall","followers_url":"https://api.github.com/users/kevinmehall/followers","following_url":"https://api.github.com/users/kevinmehall/following{/other_user}","gists_url":"https://api.github.com/users/kevinmehall/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinmehall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinmehall/subscriptions","organizations_url":"https://api.github.com/users/kevinmehall/orgs","repos_url":"https://api.github.com/users/kevinmehall/repos","events_url":"https://api.github.com/users/kevinmehall/events{/privacy}","received_events_url":"https://api.github.com/users/kevinmehall/received_events","type":"User","site_admin":false},"created_at":"2015-05-14T00:34:45Z","updated_at":"2015-05-14T00:34:45Z","body":"Or at least when the CLI has received notification of process exit and stdout and stderr EOF. The stdin and control streams' EOF is controlled by the CLI. If the process waits for stdin EOF, it will simply not exit until it receives it."}}