Interpret Logcat entry: threadid=8: still suspended after undo (sc=1 dc=1 s=Y)
Asked Answered
S

3

6

I am running around ten AsyncTasks after my application starts. Sometimes the emulator takes a long time to start these tasks. When this occurs, I see the following message in the log cat:

D/dalvikvm(1983): threadid=8: still suspended after undo (sc=1 dc=1 s=Y)

When the emulator executes quickly this message doesn't appear. Strangely, this behavior changed today without any modifications. Since I have explicitly assigned 512mb ram to the emulator, it is no longer extremely slow ~5min, now ~5s. On a real device I never have execution that slow.

I would like to understand what this log cat message means. I understand that the thread with the specified id is suspended and not working while in this state. But why? After what undo? What does (sc=1 dc=1 s=Y) mean?

Shadoof answered 10/3, 2012 at 19:4 Comment(0)
U
4

The message comes from dvmSuspendSelf(), which threads call when the debugger (via the JDWP thread) has asked them to suspend.

The way it's supposed to work is (where "we" are a thread):

  • JDWP asks us to suspend
  • we tell it we've suspended and go to sleep
  • eventually, debugger wakes us up and we resume

The message is logged when the condition variable the VM is waiting on signals, but for some reason we're still marked as suspended. The code notes:

/*
 * The condition was signaled but we're still suspended.  This
 * can happen if the debugger lets go while a SIGQUIT thread
 * dump event is pending (assuming SignalCatcher was resumed for
 * just long enough to try to grab the thread-suspend lock).
 */

The expectation in this case is that we got woken up unexpectedly when a signal arrived (e.g. system_server thinks there's an ANR because the main thread isn't responding because the debugger has suspended it), and if we loop around again the debugger will get a chance to clean us up and set us on our way.

The log message is printing the values of self->suspendCount (how many times have we been told to suspend ourselves), self->dbgSuspendCount (how many of those suspend requests came from the debugger, so we can "undo" all those if the debugger disconnects), and the value of the self->isSuspended boolean.

Note the "s=Y" flag disappeared in gingerbread -- the way thread suspension works was changed.

Unitarianism answered 29/7, 2013 at 17:38 Comment(0)
I
4

This thread is old but this answer should provide useful for users stumbling across this question months later.

Quoting a user's reply on a google group thread

There's a weird interaction between the VM and your debugger. The thread suspended itself and then waited to be woken. However, when it was woken the thread was still marked as being suspended (s=1) by the debugger (d=1).

I've come across this on the emulator and on the phone itself. If the debugger is disconnected from the device (be it emulated or real), this error condition is reset. I have found no other way of escaping the problem.

Another SO answer claims this is due to debug breakpoints being out of sync - DexFile.class error in eclipse

You can try that too.

HTH

Intercommunion answered 19/2, 2013 at 12:11 Comment(1)
Thanks a lot! I would like to mark yours as half the answer. Sounds possible, s=suspended/y=yes and dc maybe debugger context. SC i can not imagine yet and the undo i don't understand as well. I can also imagine it has something to do with breakpoints. Compared to the linked threads i had no exception, just a very slow behaviour. I can not reproduce this situation one year ago. But before when i deleted all breakpoints i had no such message, and some minutes ago with breakpoints i had that messages... :)Shadoof
U
4

The message comes from dvmSuspendSelf(), which threads call when the debugger (via the JDWP thread) has asked them to suspend.

The way it's supposed to work is (where "we" are a thread):

  • JDWP asks us to suspend
  • we tell it we've suspended and go to sleep
  • eventually, debugger wakes us up and we resume

The message is logged when the condition variable the VM is waiting on signals, but for some reason we're still marked as suspended. The code notes:

/*
 * The condition was signaled but we're still suspended.  This
 * can happen if the debugger lets go while a SIGQUIT thread
 * dump event is pending (assuming SignalCatcher was resumed for
 * just long enough to try to grab the thread-suspend lock).
 */

The expectation in this case is that we got woken up unexpectedly when a signal arrived (e.g. system_server thinks there's an ANR because the main thread isn't responding because the debugger has suspended it), and if we loop around again the debugger will get a chance to clean us up and set us on our way.

The log message is printing the values of self->suspendCount (how many times have we been told to suspend ourselves), self->dbgSuspendCount (how many of those suspend requests came from the debugger, so we can "undo" all those if the debugger disconnects), and the value of the self->isSuspended boolean.

Note the "s=Y" flag disappeared in gingerbread -- the way thread suspension works was changed.

Unitarianism answered 29/7, 2013 at 17:38 Comment(0)
B
0

Me too come across the problem. Simply just because after I started a new Thread(), I tried to access the stuff in the thread that had already been suspended. Removed that code, and the problem is resolved.

HTH

Bluetongue answered 29/7, 2013 at 9:19 Comment(1)
Hi. Can you explain a bit more? My app creates a new Thread when the activity starts (onCreate) and this error appears and prevents the app from working on LG Optimus phones...Biconvex

© 2022 - 2024 — McMap. All rights reserved.