-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Bug in use of STL queue with asynchronous signals [sf#7] #7
Comments
Commented by raywilhe on 2008-10-07 20:32 UTC template<typename TYPE> void push(const TYPE& val) unsigned int size() const const TYPE& front() const const TYPE& back() const TYPE& front() TYPE& back() protected: }; |
Commented by crayzeewulf on 2008-10-11 21:44 UTC Thank you very much for posting your solution.Crayzee Wulf |
Commented by tommysp on 2011-01-07 14:56 UTC But as I discorverd, using mutex_lock inside an Signal handler is not such a good thing. It causes some awfull deadlocks. (not often, but it does) This is also mentioned in the man page. "ASYNC-SIGNAL SAFETY I suggest the use of a extra thread to handle the work of the SIGINT, and notify it in the SignalHandler only. In the thread it is ovious to use the locks. |
Commented by crayzeewulf on 2011-01-07 21:50 UTC Thanks for the report. I think your analysis makes sense. I am going to try and reproduce this at my end. Placing a mutex around the access to the STL queue. Thanks,CrayzeeWulf |
Commented by oschwa2s on 2013-11-25 19:41 UTC |
Reported by crayzeewulf on 2008-10-03 23:12 UTC
See the following message for a full description:
https://sourceforge.net/forum/message.php?msg\_id=5363412
By: raywilhe
In tracking down program crashes, I think I might have found a bug in the libserial
read code.
From what I can tell, serial port reads happen through a signal handler function
which fills a stl queue with data. The SerialPort::Read() functions then pull
data from that stl queue.
The stl queue that passes information between the SignalHandler and the
SerialPort::Read() functions has no protections (e.g. mutex) to prevent simultaneous
access to the stl queue.
Since the SIGIO signal can interrupt the user's thread at anytime, this can
cause problems if you are lucky enough to have the folllowing happen:
the SIGIO signal is raised and the SerialPort::HandlePosixSignal()
gets immediately called
function is called
finishes
Please let me know if anybody can confirm/deny that this is a problem. This
is my first time looking at the internals of libSerial, but thus far I am fairly
sure the above described problem is the smoking gun in my case.
The text was updated successfully, but these errors were encountered: