[Mono-bugs] [Bug 685837] New: SIGSEGV in custom TableViewCell while downloading picture(might be a bug in WebClient)

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Apr 7 07:37:40 EDT 2011


https://bugzilla.novell.com/show_bug.cgi?id=685837

https://bugzilla.novell.com/show_bug.cgi?id=685837#c0


           Summary: SIGSEGV in custom TableViewCell while downloading
                    picture(might be a bug in WebClient)
    Classification: Mono
           Product: MonoTouch
           Version: unspecified
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Critical
          Priority: P5 - None
         Component: Runtime
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: liiir1985 at hotmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Customer
           Blocker: ---


Description of Problem:
I'm using currently MonoTouch 3.2.6 student edition, and made a custom
TableViewCell, which contains a picture from the internet, so I need to
download the picture from the internet. In order not to block the main ui
thread, I used ThreadPool to download the Picture. The TableView load at
startup without any problem, but if I try to scroll down or up the TableView,
it'll then randomly crash with a SIGSEGV. It may not happen immediatly after I
scroll but it'll always crash if I keep scrolling before all the picture are
loaded.

Here is the GetCell Method of my UITableViewSource:
        public override UITableViewCell GetCell(UITableView tableView,
NSIndexPath indexPath)
        {
            UITableViewCell cell = null;// =
tableView.DequeueReusableCell(idenfier);
            Post post = posts[indexPath.Row];
            InvokeOnMainThread(() =>    //just experimental, make no difference
when I remove it, just wanna be sure the bug isn't here
            {
                PostTableCell customCell;
                lock (cells)
                {
                    cells.TryGetValue(post.id, out customCell);
                    if (customCell == null)
                    {
                        customCell = new PostTableCell();
                        cell = customCell.Cell;
                        cell.Tag = post.id;
                        cells.Add(cell.Tag, customCell);
                    }
                    else
                    {
                        customCell = cells[post.id];
                        cell = customCell.Cell;
                    }
                }
                lock (customCell)
                {
                    customCell.Tags = post.tags;
                    customCell.ImageUrl = post.preview_url;
                    customCell.Resolution = "1024*768";
                }
            });
            return cell;
        }

And here is the ImageUrl setter of my custom cell:

        public string ImageUrl
        {
            set
            {
                try
                {
                    if (!set)
                    {
                        set = true;
                        ThreadPool.QueueUserWorkItem((state) =>
                        {
                            try
                            {
                                string _UserAgent = "Mozilla/4.0 (compatible;
MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)";
                                NSData data = null;
                                lock (MoeManager.Instance.WebClient)//It's only
a customWebClient with timeout, no difference if I use standard WebClient
                                {
                                    try
                                    {
                                       
MoeManager.Instance.WebClient.Headers[HttpRequestHeader.UserAgent] =
_UserAgent;
                                        while
(MoeManager.Instance.WebClient.IsBusy)
                                            Thread.Sleep(100);
                                        byte[] buffer =
MoeManager.Instance.WebClient.DownloadData((string)state);
                                        data = NSData.FromArray(buffer);
                                    }
                                    catch (Exception ex)
                                    {
                                    }
                                }
                                UIImage img = UIImage.LoadFromData(data);
                                BeginInvokeOnMainThread(() =>
                                {
                                    try
                                    {
                                        lock (this)
                                        {
                                            image.Image = img;

                                            image.ContentMode =
UIViewContentMode.ScaleAspectFit;

                                            if (indicator.IsAnimating)
                                                indicator.StopAnimating();
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.ToString());
                                    }
                                });
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex);
                            }
                        }, value);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
        }

And after hours of debuging, I finally find out, there could be something wrong
with WebClient! Because if I change byte[] buffer =
MoeManager.Instance.WebClient.DownloadData((string)state);
into:
byte[] buffer = new byte[0];

It'll then print the exception that buffer should not be null, as expected. But
program won't crash anymore.(And I'm sure there's nothing wrong with internet
connection and the content it's downloading)

Steps to reproduce the problem:
1. Scroll down or up the TableView with CustomTableViewCell.


Actual Results:
It crashes with SIGSEGV

Expected Results:
It should load all pictures asynchron

How often does this happen? 
Almost everytime I scroll up or down

Additional Information:

Call stack while crashing
public class Application
    {
        static void Main (string[] args)
        {
            UIApplication.Main (args);    <========== NullPointerReference
Exception        
        }
    }

Stacktrace:

  at (wrapper managed-to-native)
MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr)
<0x00004>
  at (wrapper managed-to-native)
MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr)
<0x00004>
  at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00038] in
/Users/plasma/Source/iphone-3/monotouch/UIKit/UIApplication.cs:26
  at MonoTouch.UIKit.UIApplication.Main (string[]) [0x00000] in
/Users/plasma/Source/iphone-3/monotouch/UIKit/UIApplication.cs:31
  at Subscriber.Application.Main (string[]) [0x00000] in
/Users/liiir1985/Projects/Imouto/Subscriber/Main.cs:15
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object
(object,intptr,intptr,intptr) <IL 0x0001d, 0x00090>

Native stacktrace:

    0   Subscriber                          0x000be9db
mono_handle_native_sigsegv + 343
    1   Subscriber                          0x0000e7a6
mono_sigsegv_signal_handler + 313
    2   libSystem.B.dylib                   0x920cd45b _sigtramp + 43
    3   ???                                 0xffffffff 0x0 + 4294967295
    4   libobjc.A.dylib                     0x029d128b class_respondsToSelector
+ 59
    5   CoreFoundation                      0x00e0a8a9 ___forwarding___ + 777
    6   CoreFoundation                      0x00e0a522 _CF_forwarding_prep_0 +
50
    7   UIKit                               0x01d21b98
-[UITableView(UITableViewInternal)
_createPreparedCellForGlobalRow:withIndexPath:] + 634
    8   UIKit                               0x01d174cc
-[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75
    9   UIKit                               0x01d2c8cc
-[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
    10  UIKit                               0x01d2490c -[UITableView
layoutSubviews] + 242
    11  QuartzCore                          0x03189a5a -[CALayer
layoutSublayers] + 181
    12  QuartzCore                          0x0318bddc CALayerLayoutIfNeeded +
220
    13  QuartzCore                          0x031310b4
_ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
    14  QuartzCore                          0x03132294
_ZN2CA11Transaction6commitEv + 292
    15  QuartzCore                          0x0313246d
_ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99
    16  CoreFoundation                      0x00e7a89b
__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27
    17  CoreFoundation                      0x00e0f6e7 __CFRunLoopDoObservers +
295
    18  CoreFoundation                      0x00dd81d7 __CFRunLoopRun + 1575
    19  CoreFoundation                      0x00dd7840 CFRunLoopRunSpecific +
208
    20  CoreFoundation                      0x00dd7761 CFRunLoopRunInMode + 97
    21  GraphicsServices                    0x040261c4 GSEventRunModal + 217
    22  GraphicsServices                    0x04026289 GSEventRun + 115
    23  UIKit                               0x01cbac93 UIApplicationMain + 1160
    24  ???                                 0x077ee9b2 0x0 + 125757874
    25  ???                                 0x077ee782 0x0 + 125757314
    26  ???                                 0x077eddea 0x0 + 125754858
    27  ???                                 0x077edc3c 0x0 + 125754428
    28  ???                                 0x077edcf1 0x0 + 125754609
    29  Subscriber                          0x0000e56a mono_jit_runtime_invoke
+ 1360
    30  Subscriber                          0x001c961b mono_runtime_invoke +
137
    31  Subscriber                          0x001cb2d7 mono_runtime_exec_main +
714
    32  Subscriber                          0x001cabfd mono_runtime_run_main +
812
    33  Subscriber                          0x00095354 mono_jit_exec + 200
    34  Subscriber                          0x0027d299 main + 3494
    35  Subscriber                          0x00003009 _start + 208
    36  Subscriber                          0x00002f38 start + 40

Debug info from gdb:


=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

warning: .o file
"/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch.a(monotouch-glue.x86.o)"
more recent than executable timestamp in "/Users/liiir1985/Library/Application
Support/iPhone
Simulator/4.3/Applications/F41EFB7C-595F-410B-AE98-D469748E1152/Subscriber.app/Subscriber"
warning: Could not open OSO file
/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch.a(monotouch-glue.x86.o)
to scan for pubtypes for objfile /Users/liiir1985/Library/Application
Support/iPhone
Simulator/4.3/Applications/F41EFB7C-595F-410B-AE98-D469748E1152/Subscriber.app/Subscriber
warning: .o file
"/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch.a(monotouch-x86.double-abi-stret-trampoline.o)"
more recent than executable timestamp in "/Users/liiir1985/Library/Application
Support/iPhone
Simulator/4.3/Applications/F41EFB7C-595F-410B-AE98-D469748E1152/Subscriber.app/Subscriber"
warning: Could not open OSO file
/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch.a(monotouch-x86.double-abi-stret-trampoline.o)
to scan for pubtypes for objfile /Users/liiir1985/Library/Application
Support/iPhone
Simulator/4.3/Applications/F41EFB7C-595F-410B-AE98-D469748E1152/Subscriber.app/Subscriber
warning: .o file
"/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch.a(gc.x86.o)"
more recent than executable timestamp in "/Users/liiir1985/Library/Application
Support/iPhone
Simulator/4.3/Applications/F41EFB7C-595F-410B-AE98-D469748E1152/Subscriber.app/Subscriber"
warning: Could not open OSO file
/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch.a(gc.x86.o)
to scan for pubtypes for objfile /Users/liiir1985/Library/Application
Support/iPhone
Simulator/4.3/Applications/F41EFB7C-595F-410B-AE98-D469748E1152/Subscriber.app/Subscriber
warning: .o file
"/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch.a(zlib-helper.x86.o)"
more recent than executable timestamp in "/Users/liiir1985/Library/Application
Support/iPhone
Simulator/4.3/Applications/F41EFB7C-595F-410B-AE98-D469748E1152/Subscriber.app/Subscriber"
warning: Could not open OSO file
/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch.a(zlib-helper.x86.o)
to scan for pubtypes for objfile /Users/liiir1985/Library/Application
Support/iPhone
Simulator/4.3/Applications/F41EFB7C-595F-410B-AE98-D469748E1152/Subscriber.app/Subscriber
warning: Could not find object file
"/var/folders/Ny/NyElTwhDGD8kZMqIEeLGXE+++TI/-Tmp-//ccvRqNHg.o" - no debug
information available for "template.m".

warning: .o file
"/Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc.a(_divdi3.o)" more
recent than executable timestamp in "/Users/liiir1985/Library/Application
Support/iPhone
Simulator/4.3/Applications/F41EFB7C-595F-410B-AE98-D469748E1152/Subscriber.app/Subscriber"
warning: Could not open OSO file
/Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc.a(_divdi3.o) to scan
for pubtypes for objfile /Users/liiir1985/Library/Application Support/iPhone
Simulator/4.3/Applications/F41EFB7C-595F-410B-AE98-D469748E1152/Subscriber.app/Subscriber
warning: .o file
"/Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc.a(_moddi3.o)" more
recent than executable timestamp in "/Users/liiir1985/Library/Application
Support/iPhone
Simulator/4.3/Applications/F41EFB7C-595F-410B-AE98-D469748E1152/Subscriber.app/Subscriber"
warning: Could not open OSO file
/Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc.a(_moddi3.o) to scan
for pubtypes for objfile /Users/liiir1985/Library/Application Support/iPhone
Simulator/4.3/Applications/F41EFB7C-595F-410B-AE98-D469748E1152/Subscriber.app/Subscriber
warning: .o file
"/Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc.a(_udivdi3.o)" more
recent than executable timestamp in "/Users/liiir1985/Library/Application
Support/iPhone
Simulator/4.3/Applications/F41EFB7C-595F-410B-AE98-D469748E1152/Subscriber.app/Subscriber"
warning: Could not open OSO file
/Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc.a(_udivdi3.o) to scan
for pubtypes for objfile /Users/liiir1985/Library/Application Support/iPhone
Simulator/4.3/Applications/F41EFB7C-595F-410B-AE98-D469748E1152/Subscriber.app/Subscriber
warning: .o file
"/Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc.a(_umoddi3.o)" more
recent than executable timestamp in "/Users/liiir1985/Library/Application
Support/iPhone
Simulator/4.3/Applications/F41EFB7C-595F-410B-AE98-D469748E1152/Subscriber.app/Subscriber"
warning: Could not open OSO file
/Developer/usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc.a(_umoddi3.o) to scan
for pubtypes for objfile /Users/liiir1985/Library/Application Support/iPhone
Simulator/4.3/Applications/F41EFB7C-595F-410B-AE98-D469748E1152/Subscriber.app/Subscriber
warning: .o file
"/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch.a(monotouch-glue.x86.o)"
more recent than executable timestamp in "/Users/liiir1985/Library/Application
Support/iPhone
Simulator/4.3/Applications/F41EFB7C-595F-410B-AE98-D469748E1152/Subscriber.app/Subscriber"
warning: Couldn't open object file
'/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib/libmonotouch.a(monotouch-glue.x86.o)'

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list