race-condition

Current state of drd and helgrind support for std::thread

一世执手 提交于 2019-11-30 18:13:06
As I transition my code to C++11, I would very much like to convert my pthread code to std::thread. However, I seem to be getting false race conditions on very simple programs in drd and in helgrind. #include <thread> int main(int argc, char** argv) { std::thread t( []() { } ); t.join(); return 0; } Helgrind output snippet - I also get similar errors in drd, using gcc 4.6.1, valgrind 3.7.0 on Ubuntu 11.11 amd64. My questions are: sanity check: Am I doing anything wrong? Are others getting similar false reports on simple std::thread programs? What are current users of std::thread using to

Race-condition creating folder in Python

蓝咒 提交于 2019-11-30 17:24:00
I have a urllib2 caching module, which sporadically crashes because of the following code: if not os.path.exists(self.cache_location): os.mkdir(self.cache_location) The problem is, by the time the second line is being executed, the folder may exist, and will error: File ".../cache.py", line 103, in __init__ os.mkdir(self.cache_location) OSError: [Errno 17] File exists: '/tmp/examplecachedir/' This is because the script is simultaneously launched numerous times, by third-party code I have no control over. The code (before I attempted to fix the bug) can be found here, on github I can't use the

Chrome Extension error: “Unchecked runtime.lastError while running browserAction.setIcon: No tab with id”

烈酒焚心 提交于 2019-11-30 07:58:00
问题 I'm coding my Google Chrome Extension where I set the app's icon from the background script as such: try { objIcon = { "19": "images/icon19.png", "38": "images/icon38.png" }; chrome.browserAction.setIcon({ path: objIcon, tabId: nTabID }); } catch(e) { } Note that I wrapped the call in try/catch block. Still, sometimes I'm getting the following message in the console log: Unchecked runtime.lastError while running browserAction.setIcon: No tab with id: 11618. It's hard to debug this error

How to properly avoid Mysql Race Conditions

烂漫一生 提交于 2019-11-30 05:22:58
问题 I know this has been asked before, but I'm still confused and would like to avoid any problems before I go into programming if possible. I plan on having an internal website with at least 100 users active at any given time. Users would post an item (inserted into db with a 0 as its value) and that item would be shown via a php site (db query). Users then get the option to press a button and lock that item as theirs (assign the value of that item as their id) How do I ensure that 2 or more

Is it safe if more git commands are run on the same repo in parallel?

本小妞迷上赌 提交于 2019-11-30 04:43:28
I am interested if it is safe to run things like git push and git commit in parallel (for example in cron jobs, jenkins jobs etc.). Is there some locking mechanism built-in in git so these operations are serialized or this can corrupt the repository? Yes. Git works by writing references in a manner that allows for this. If you are doing a commit at the same time as a push, push will only go from the references down to the objects they contain. If the commit finishes and updates the branch reference on time, it will get pushed. If it doesn't, the old reference will be pushed. You won't get

Meteor: Could a race condition happen with Meteor.collections on server side?

為{幸葍}努か 提交于 2019-11-30 04:27:50
问题 in my server/server.js Meteor.methods({ saveOnServer: function() { var totalCount = Collections.find({ "some": "condition" }).count(); if (totalCount) { var customerId = Collections.update('someId', { "$addToSet": { objects: object } }, function(err) { if (err) { throw err; } else { return true; } }); } else {} } }); I'm afraid that when saveOnServer() is called by 2 clients at the same time, it will return the same totalCount for each client and basically end up inserting same integer number

Is it possible to store pointers in shared memory without using offsets?

只谈情不闲聊 提交于 2019-11-30 03:48:42
问题 When using shared memory, each process may mmap the shared region into a different area of its respective address space. This means that when storing pointers within the shared region, you need to store them as offsets of the start of the shared region. Unfortunately, this complicates use of atomic instructions (e.g. if you're trying to write a lock free algorithm). For example, say you have a bunch of reference counted nodes in shared memory, created by a single writer. The writer

Concurrently reading a Map while a single background thread regularly modifies it

一个人想着一个人 提交于 2019-11-30 03:10:47
问题 I have a class in which I am populating a map liveSocketsByDatacenter from a single background thread every 30 seconds inside updateLiveSockets() method and then I have a method getNextSocket() which will be called by multiple reader threads to get a live socket available which uses the same map to get this information. public class SocketManager { private static final Random random = new Random(); private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor()

Current state of drd and helgrind support for std::thread

橙三吉。 提交于 2019-11-30 01:53:22
问题 As I transition my code to C++11, I would very much like to convert my pthread code to std::thread. However, I seem to be getting false race conditions on very simple programs in drd and in helgrind. #include <thread> int main(int argc, char** argv) { std::thread t( []() { } ); t.join(); return 0; } Helgrind output snippet - I also get similar errors in drd, using gcc 4.6.1, valgrind 3.7.0 on Ubuntu 11.11 amd64. My questions are: sanity check: Am I doing anything wrong? Are others getting

How to avoid race condition in MySQL

妖精的绣舞 提交于 2019-11-29 23:46:06
问题 I've got a potential race condition in an application I'm developing, which I'd like to account for and avoid in my querying. To summarise the application flow... Create a new row in the entries table: INSERT INTO entries ( name, email ) VALUES ( 'Foo Bar', 'foo@example.com' ); Find out if Mr Bar is a winner by checking a time-sensitive prizes table: SELECT id FROM prizes WHERE various_time_conditions = 'met' AND id NOT IN ( SELECT prize_id FROM entries ); If he's a winner, update his entry