Wink Saville’s Blog

January 18, 2008

Android - Bug: Thread hangs writing to outer class variable

Filed under: Android, programming — wink @ 12:07 pm

Below is an bug I reported to android-developers and android-bug, it is quite strange, while executing an assignment statement the code just hangs. No errors, exceptions nothing.

Hello,

A possible bug that seems to be associated with accessing
variables of an outer class from an inner class that is a Runnable.
Maybe its a bug in my code, but I don’t see it and if it is
I wouldn’t have expected Java code to just hang on an
“assignment” statement.

In this file:
http://async-msgcomp.googlecode.com/svn/trunk/android/mc/src/com/saville/android/mc/McMgr.java
If lines 216 or 218 are commented out:

214             /** ******************************************************************************** */
215             /* FIXME: Next statement required to see “… run() 2″ below */
216             mSecondaryPort.get();
217             /* FIXME: Next statement required to see “… run() 3″ below */
218             mServerRunning = 0;
219             /** ******************************************************************************** */

Then the Thread started will stop execution with no error at line 241 or 244:

238             /** ******************************************************************************** */
239             Log.v(df, “%s: McServer; run() 1″, mName);
240             /* FIXME: We’ll die if mSecondary.get() isn’t in McServer() */
241             mSecondaryPort.set(mPort + 1);
242             Log.v(df, “%s: McServer; run() 2″, mName);
243             /* FIXME: We’ll die if mServerRunnging=0 isn’t in McServer() */
244             mServerRunning = 1;
245             Log.v(df, “%s: McServer; run() 3″, mName);
246             /** ******************************************************************************** */

The entire code base is from Revision 13 of this repository for http://async-msgcomp.googlecode.com
There are several applicatons in this repository the one in question is “android/mc”.
I tried to make a simpler test but as would be expected it didn’t fail.

I’m running m37a on Linux:

wink@ic2d1:$ uname -a
Linux ic2d1 2.6.22-14-generic #1 SMP Tue Dec 18 05:28:27 UTC 2007 x86_64 GNU/Linux

Feel free to contact me  <first name>@<last name>.com if any
additional information is needed.

Regards,

Wink Saville

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress