{"action":"opened","issue":{"url":"https://api.github.com/repos/crayzeewulf/libserial/issues/30","labels_url":"https://api.github.com/repos/crayzeewulf/libserial/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/crayzeewulf/libserial/issues/30/comments","events_url":"https://api.github.com/repos/crayzeewulf/libserial/issues/30/events","html_url":"https://github.com/crayzeewulf/libserial/issues/30","id":84776860,"number":30,"title":"Bug in use of STL queue with asynchronous signals","user":{"login":"crayzeewulf","id":2294944,"avatar_url":"https://avatars.githubusercontent.com/u/2294944?v=3","gravatar_id":"","url":"https://api.github.com/users/crayzeewulf","html_url":"https://github.com/crayzeewulf","followers_url":"https://api.github.com/users/crayzeewulf/followers","following_url":"https://api.github.com/users/crayzeewulf/following{/other_user}","gists_url":"https://api.github.com/users/crayzeewulf/gists{/gist_id}","starred_url":"https://api.github.com/users/crayzeewulf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crayzeewulf/subscriptions","organizations_url":"https://api.github.com/users/crayzeewulf/orgs","repos_url":"https://api.github.com/users/crayzeewulf/repos","events_url":"https://api.github.com/users/crayzeewulf/events{/privacy}","received_events_url":"https://api.github.com/users/crayzeewulf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-03T21:24:02Z","updated_at":"2015-06-03T21:24:02Z","closed_at":null,"body":"**Reported by crayzeewulf on 2008-10-03 23:12 UTC**\nSee the following message for a full description:\r\n\r\nhttps://sourceforge.net/forum/message.php?msg\\_id=5363412\r\n\r\nBy: raywilhe\r\n\r\nIn tracking down program crashes, I think I might have found a bug in the libserial\r\nread code.\r\n\r\nFrom what I can tell, serial port reads happen through a signal handler function\r\nwhich fills a stl queue with data.  The SerialPort::Read\\(\\) functions then pull\r\ndata from that stl queue.\r\n\r\nThe stl queue that passes information between the SignalHandler and the\r\nSerialPort::Read\\(\\) functions has no protections \\(e.g. mutex\\) to prevent simultaneous\r\naccess to the stl queue.\r\n\r\nSince the SIGIO signal can interrupt the user's thread at anytime, this can\r\ncause problems if you are lucky enough to have the folllowing happen:\r\n\r\n\r\n1\\. User Calls SerialPort::ReadByte\\(\\)\r\n2\\. In the middle of executing the mInputBuffer.pop\\(\\) function call\r\nthe SIGIO signal is raised and the SerialPort::HandlePosixSignal\\(\\)\r\ngets immediately called\r\n3\\. In the  SerialPort::HandlePosixSignal\\(\\) function, the mInputBuffer.push\\(\\)\r\nfunction is called\r\n4\\. Execution returns back to SerialPort::ReadByte\\(\\), and the mInputBuffer.pop\\(\\)\r\nfinishes\r\n5\\. Now the stl queue is corrupted and the random crashes start.....\r\n\r\nPlease let me know if anybody can confirm/deny that this is a problem.  This\r\nis my first time looking at the internals of libSerial, but thus far I am fairly\r\nsure the above described problem is the smoking gun in my case.\r\n\r\n"}}