Weird and rather worrying.  I cannot explain this stacktrace at all as the
UserLog class is thread safe as far as I can see and in fact has been in
production across multiple platforms for years.
Sorry, I don't have the actual exception message, there did not appear to be
one in the logcat output.
It looks to me like the string got trashed in some way.  At first I thought
it might be a problem with locking on static variables, so I knocked up a
sample app with 50 threads sleeping randomly and writing to UserLog class,
but I couldn't replicate the crash...

Deployed on a Motorola Xoom, built in release mode, built with both armeabi
and armeab-v7a selected for supported architectures.
Only slightly nonstandard thing I can think of is that UserLog is in a
library dll which is built with a minimum target platform version of 1.6
whereas the app was built to target 2.2.

Any ideas anyone?

Cheers
Iain


I/mono    ( 1743): Stacktrace:
I/mono    ( 1743):
I/mono    ( 1743):   at string.Remove (int,int) <0x0003f>
I/mono    ( 1743):   at *****.UserLog.ClipLogText () <0x00053>
I/mono    ( 1743):   at *****.UserLog.WriteLine (string) <0x00163>
I/mono    ( 1743):   at *****.ControlPoint.Upnp.DeviceListUpnp.Rescan ()
<0x00123>
I/mono    ( 1743):   at *****.Library.Rescan () <0x00023>
I/mono    ( 1743):   at *****.Stack.<InitialiseStack>b__1
(object,System.Timers.ElapsedEventArgs) <0x0007f>
I/mono    ( 1743):   at System.Timers.Timer.Callback (object) <0x00423>
I/mono    ( 1743):   at System.Threading.Timer/Scheduler.TimerCB (object)
<0x0019f>
I/mono    ( 1743):   at (wrapper runtime-invoke)
<Module>.runtime_invoke_void__this___object (object,intptr,intptr,intpt
r) <0xffffffff>



    public class UserLog
    {
        public static void Write(string aMessage)
        {
            lock (iLock)
            {
                foreach (IUserLogListener listener in iListenerList)
                {
                    try
                    {
                        listener.Write(aMessage);
                    }
                    catch (Exception) { }
                }

                iLogText += aMessage;
                ClipLogText();
            }
        }

        public static void WriteLine(string aMessage)
        {
            lock (iLock)
            {
                foreach (IUserLogListener listener in iListenerList)
                {
                    try
                    {
                        listener.WriteLine(aMessage);
                    }
                    catch (Exception) { }
                }

                iLogText += aMessage + Environment.NewLine;
                ClipLogText();
            }
        }

        public static void AddListener(IUserLogListener aListener)
        {
            lock (iLock)
            {
                iListenerList.Add(aListener);
            }
        }

        public static void RemoveListener(IUserLogListener aListener)
        {
            lock (iLock)
            {
                iListenerList.Remove(aListener);
            }
        }

        public static string Text
        {
            get
            {
                lock (iLock)
                {
                    return iLogText;
                }
            }
        }

        private static void ClipLogText()
        {
            if (iLogText.Length >= kMaxTextLength)
            {
                iLogText = iLogText.Remove(0, iLogText.Length -
kMaxTextLength);
            }
        }

        private static readonly int kMaxTextLength = 32767;

        private static string iLogText = "";
        private static object iLock = new object();
        private static List<IUserLogListener> iListenerList = new
List<IUserLogListener>();
    }
_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to