Path: csiph.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!news.glorb.com!usenet.stanford.edu!not-for-mail From: Larry Campbell Newsgroups: gnu.gnustep.bug Subject: [bug #46956] Thread safety issues in NSUserDefaults.m cause unwarranted exceptions to be raised Date: Sat, 23 Jan 2016 21:24:47 +0000 Lines: 31 Approved: bug-gnustep@gnu.org Message-ID: References: <20160123-211950.sv28252.3225@savannah.gnu.org> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain;charset=UTF-8 X-Trace: usenet.stanford.edu 1453584293 32522 208.118.235.17 (23 Jan 2016 21:24:53 GMT) X-Complaints-To: action@cs.stanford.edu To: Larry Campbell , bug-gnustep@gnu.org Envelope-to: bug-gnustep@gnu.org X-PHP-Originating-Script: 0:sendmail.php X-Savane-Server: savannah.gnu.org:443 [208.118.235.70] X-Savane-Project: gnustep X-Savane-Tracker: bugs X-Savane-Item-ID: 46956 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9 X-Apparently-From: 73.238.182.241 (Savane authenticated user lcampbel) In-Reply-To: <20160123-211950.sv28252.3225@savannah.gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:6::a X-BeenThere: bug-gnustep@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for the GNUstep programming environment List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.gnustep.bug:4078 Follow-up Comment #1, bug #46956 (project gnustep): (sorry for the formatting; don't know how to get bugzilla to preserve indentation) Part, but not all, of the problem is that parsingArguments is being protected by the _lock ivar, but because parsingArguments is file static, and you can have multiple NSUserDefaults objects in play, that's not sufficient. You need to use classLock here. But you can still end up with the second thread trying to call _createArgumentDictionary getting a nil arguments dictionary. Since my applications don't use that, I stopped there. I'll shortly be attaching a patch that fixes that, and that adds a sleep-and-retry loop for the case where some thread needs the standardUserDefaults but another thread is still in the process of creating it. We probably need a similar sleep-and-retry loop for _createArgumentDictionary but I didn't go that far because, as I said, I don't use it. _______________________________________________________ Reply to this item at: _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/