48 ms·
'If XInitThreads() is not called anywhere in a multi-tasked program, the program will usually work. But weird crashes and other race conditions are bound to hap
by jonny383 7y ago
'If XInitThreads() is not called anywhere in a multi-tasked program, the program will usually work. But weird crashes and other race conditions are bound to happen over time, as Xlib maintains some global data that is shared across all threads and all "displays".'
Is there a reason you can't catch this with static analysis tests? Also, I don't really see this as an issue with xlib any more than I see it as an issue with a careless developer who didn't read documentation or check or examples.
- bluecmd 7y agoHostile APIs are a problem. If you require a dance for the correct outcome, people will fail. Make it easy to do the right thing.
- josefx 7y agoMulti threading usually involves a dance to get the correct outcome. Xlib does that for you with a single call at the start of the program or you can do it yourself with every function call you want to make.
- cjfd 7y agoPresumably you will also be okay in a multi-threaded program if only one thread touches Xlib. That would be the sensible way to write a GUI anyway because multi-threading should only be used if it is necessary and not just for the heck of it. If expensive computation is used to calculate the things displayed in the GUI, this should be done by worker threads while the GUI does not need to be multi-threaded. If, on the other hand, one depends on external processes it makes more sense to use a single thread but use it asynchronously. Very few GUI benefit from multi-threading. Note that javascript is also executed single threadedly in browsers.
- josefx 7y ago> Note that javascript is also executed single threadedly in browsers. Currently browsers run multiple processes for their UI and the loaded websites. Back when this wasn't the case it took just a single badly behaving site to hang everything.
- cjfd 7y agoThat is not at all or in any way what I said......