deadlock

performBlockAndWait creates deadlock

纵然是瞬间 提交于 2019-12-04 23:34:19
问题 I am writing a function that performs some CoreData stuff. I want the function to return only after all the CoreData operations have executed. The CoreData stuff involves creating an object in a background context, then doing some more stuff in the parent context: + (void) myFunction NSManagedObjectContext *backgroundContext = [DatabaseDelegate sharedDelegate].backgroundContext; [backgroundContext performBlockAndWait:^{ MyObject *bla = create_my_object_in:backgroundContext; [backgroundContext

how is it possible, 3 threads are in blocked state waiting same monitor, and there is no thread owned that monitor

£可爱£侵袭症+ 提交于 2019-12-04 20:25:48
In our production environment, weblogic server hangs for half an hour, It looks like it has dead-locked threads. But after investigating thread dumps, 3 threads are blocked for the same lock, but no other threads own this lock.. Here is the stacktrace .. Do you have any reasonable explanation for this stiuation?. Here is the blocked threads; "pool-1013-thread-5" prio=7 tid=600000000842be00 nid=17280 lwp_id=518677 waiting for monitor entry [9fffffffe6aff000..9fffffffe6b00bd0] java.lang.Thread.State: BLOCKED (on object monitor) at org.apache.log4j.Category.callAppenders(Category.java:201) -

Java threads and synchronized blocks

我只是一个虾纸丫 提交于 2019-12-04 19:13:38
问题 Suppose I'm executing a synchronized block of code inside some thread and within the synchronized block I call a method that spawns another thread to process a synchronized block of code that requires the same lock as the first method. So in pseudo Java code: public void someMethod() { synchronized(lock_obj) { // a whole bunch of stuff... // this is the last statement in the block (new Thread(someOtherMethod())).start(); } // some more code that doesn't require a lock } public void

How to fix a deadlock in join() in Ruby

柔情痞子 提交于 2019-12-04 17:44:16
问题 I am working in multi-threading in Ruby. The code snippet is: threads_array = Array.new(num_of_threads) 1.upto(num_of_threads) do |i| Thread.abort_on_exception = true threads_array[i-1] = Thread.new { catch(:exit) do print "s #{i}" user_id = nil loop do user_id = user_ids.pop() if user_id == nil print "a #{i}" Thread.stop() end dosomething(user_id) end end } end #puts "after thread" threads_array.each {|thread| thread.join} I am not using any mutex locks, but I get a deadlock. This is the

Clarifications on dispatch_queue, reentrancy and deadlocks

江枫思渺然 提交于 2019-12-04 16:36:08
I need a clarifications on how dispatch_queue s is related to reentrancy and deadlocks. Reading this blog post Thread Safety Basics on iOS/OS X , I encountered this sentence: All dispatch queues are non-reentrant, meaning you will deadlock if you attempt to dispatch_sync on the current queue. So, what is the relationship between reentrancy and deadlock? Why, if a dispatch_queue is non-reentrant, does a deadlock arise when you are using dispatch_sync call? In my understanding, you can have a deadlock using dispatch_sync only if the thread you are running on is the same thread where the block is

Android finding a deadlock

送分小仙女□ 提交于 2019-12-04 14:45:01
I am getting an ANR sometimes when I run my Android service. I suspect it is happening because of a deadlock. Is there an easy way to monitor deadlock in Android or Eclipse. Such as a utility to show which thread hold which lock etc.? And is there a way to figure out a deadlock by looking at traces.txt file? My ddms log looks like this at the time of crash 02-15 18:09:01.046: INFO/Process(90): Sending signal. PID: 450 SIG: 3 02-15 18:09:01.046: INFO/dalvikvm(450): threadid=3: reacting to signal 3 02-15 18:09:01.056: INFO/dalvikvm(450): Wrote stack traces to '/data/anr/traces.txt' 02-15 18:09

Why does this code deadlock?

烈酒焚心 提交于 2019-12-04 14:38:59
I created 2 Linux kernel threads in my loadable module and I bind them to separate CPU cores running on a dual core Android device. After I run this few times, I noticed that the device reboots with a HW watchdog timer reset. I hit the issue consistently. What could be causing the deadlock? Basically, what i need to do is, make sure both the threads run do_something() at the same time on different cores without anybody stealing the cpu cycles(i.e. interrupts are disabled). I am using a spinlock and a volatile variable for this. I also have a semaphore for parent thread to wait on child thread.

How to cause deadlock on MySQL

给你一囗甜甜゛ 提交于 2019-12-04 12:15:33
问题 For test purposes, I need to generate a "1213: Deadlock" on MySQL so that UPDATE query can't update a table. I am not not quite sure how to cause deadlock? 回答1: There are numerous posts for this by using two sessions. https://dba.stackexchange.com/questions/309/code-to-simulate-deadlock http://www.xaprb.com/blog/2006/08/08/how-to-deliberately-cause-a-deadlock-in-mysql/ Method copied from the second article above First, choose an unused table name. I’ll use test.innodb_deadlock_maker. Here are

EnterCriticalSection Deadlock

断了今生、忘了曾经 提交于 2019-12-04 12:09:37
Having what appears to be a dead-lock situation with a multi-threaded logging application. Little background: My main application has 4-6 threads running. The main thread responsible for monitoring health of various things I'm doing, updating GUIs, etc... Then I have a transmit thread and a receive thread. The transmit and receive threads talk to physical hardware. I sometimes need to debug the data that the transmit and receive threads are seeing; i.e. print to a console without interrupting them due to their time critical nature of the data. The data, by the way, is on a USB bus. Due to the

Postgres deadlocks on concurrent upserts

徘徊边缘 提交于 2019-12-04 11:13:27
We have an application which reads from a data stream and upserts that information into a database. The data is changes which occur on Google Drive which means that many events which impact the same objects can occur very close to each other. We're running into deadlocks when upserting this information into the database, here is what comes out in the log. I have reconstructed and sanitised the query for readability: ERROR: deadlock detected DETAIL: Process 10586 waits for ShareLock on transaction 166892743; blocked by process 10597. Process 10597 waits for ShareLock on transaction 166892741;