You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should investigate and fix, this sounds like a real problem.
@rooboios @mcmengchen @guidedways are you logging errors in that case? Because for errors, we are logging synchronously and that might somehow cause a deadlock.
Yup, was logging errors. I had to change it in a fork to not use the main thread (although the problem was elsewhere in our code that kept hammering the main thread, it was however cocoalumberjack that caused a deadlock).
@bpoplauschi I'm not a 100% sure but clearly the deadlock is there on the locks used by the dispatch queue, and so if we were simply to by pass using dispatch_sync, we would solve the problem. dispatch_sync is known to cause dead-locks (for instance calling it on the main queue from code executing on the main queue would cause it to hold the lock indefinitely).
The issue is here in DDLog.m:
if (asyncFlag) {
dispatch_async(_loggingQueue, logBlock);
} else {
dispatch_sync(_loggingQueue, logBlock); <--- causing the deadlock
}
Clearly, two background threads throwing an error at the same time is causing it to dead-lock (since they're both calling dispatch_sync on the same queue at the same time). And this is possibly what's happening in our case since we have several background worker threads, and two or three may at a given time try and DDLogError(...) at the same time.
@guidedways Adding the code you've presented would definitely improve threading situation, but I don't see it present in the stack trace you posted. Do you know if the fix you provided would also fix the stack trace in the first comment?
My hunch is that you're hitting a different issue... Anyways, I've implemented the fix you suggested in #1003
@rooboios@guidedways @mcmengchen @tar500 Can any of you reproduce this issue on the master branch? If you're able to, we'd love to see a backtrace from all threads, (via bt all).
Activity
mitchell-dream commentedon Dec 3, 2016
I have the save problem.
guidedways commentedon Apr 16, 2017
Same here! I kept pulling my hair out till I realised it's Cocoalumberjack causing this. Any fix?
bpoplauschi commentedon May 2, 2017
We should investigate and fix, this sounds like a real problem.
@rooboios @mcmengchen @guidedways are you logging errors in that case? Because for errors, we are logging synchronously and that might somehow cause a deadlock.
CC @rivera-ernesto
guidedways commentedon May 2, 2017
Yup, was logging errors. I had to change it in a fork to not use the main thread (although the problem was elsewhere in our code that kept hammering the main thread, it was however cocoalumberjack that caused a deadlock).
bpoplauschi commentedon May 3, 2017
@guidedways Any suggestions on how we can fix this in CocoaLumberjack?
guidedways commentedon May 3, 2017
@bpoplauschi I'm not a 100% sure but clearly the deadlock is there on the locks used by the dispatch queue, and so if we were simply to by pass using
dispatch_sync
, we would solve the problem.dispatch_sync
is known to cause dead-locks (for instance calling it on the main queue from code executing on the main queue would cause it to hold the lock indefinitely).The issue is here in
DDLog.m
:Clearly, two background threads throwing an error at the same time is causing it to dead-lock (since they're both calling
dispatch_sync
on the same queue at the same time). And this is possibly what's happening in our case since we have several background worker threads, and two or three may at a given time try andDDLogError(...)
at the same time.I should suggest we add the following method:
And change the code to:
That should hopefully fix it.
tar500 commentedon Jul 5, 2017
looks like it's related to #689
any update on this?
hhanesand commentedon Dec 27, 2018
@guidedways Adding the code you've presented would definitely improve threading situation, but I don't see it present in the stack trace you posted. Do you know if the fix you provided would also fix the stack trace in the first comment?
My hunch is that you're hitting a different issue... Anyways, I've implemented the fix you suggested in #1003
Implement bypass suggested in #812 (comment)
hhanesand commentedon Jan 11, 2019
@rooboios @guidedways @mcmengchen @tar500 Can any of you reproduce this issue on the master branch? If you're able to, we'd love to see a backtrace from all threads, (via
bt all
).hhanesand commentedon Feb 3, 2019
Closing due to no response. Please open a new issue with a full backtrace if you can reproduce this on version 3.5.0 or later.