[Mono-dev] Crazy StackAlloc

Zoltan Varga vargaz at gmail.com
Thu May 7 13:11:19 EDT 2009


Hi,

  mono's stack overflow handing is far from ideal, because this is very hard
to implement
correctly in all cases. We mostly aim for developer productivity (producing
a stack trace).

                                           Zoltan

On Thu, May 7, 2009 at 3:52 PM, Jambunathan K
<kjambunathan.devel at gmail.com>wrote:

> I am surprised that there is a Number Overflow exception reported in
> my earlier post.
> The earlier run had size set to 1 * 1024 * 1024. Can someone explain this?
>
> Anyways here is a run with size set to 24 * 1024 * 1024.
>
> I apologize for being incoherent and inarticulate. Yet I hope my post
> is considered.
>
> kjambunathan at kjambunathan-desktop:~/src/ws/mono-2.4/mono$ cat
> StackAllocCrazy.cs && mcs /unsafe StackAllocCrazy.cs && mono
> StackAllocCrazy.exe
> using System;
>
> class T
> {
>
>        public unsafe static void Main ()
>        {
>         int size = 24 * 1024 * 1024;
>
>        while (size != 0) {
>                Console.WriteLine ("Trying " + size + " bytes ...");
>
>                try {
>                        long *buf = stackalloc long[size];
>
>                        for (int i = 0; i < size; ++i)
>                                buf[i] = 0;
>
>                } catch (Exception e) {
>                        Console.WriteLine ("Caught " + e);
>                        size /= 2;
>                        continue;
>                }
>
>                Console.WriteLine ("Can stackalloc " + size + " longs");
>                break;
>        }
>        }
> }
> Trying 25165824 bytes ...
> Stack overflow in unmanaged: IP: 0x8108cd2, fault addr: 0xbf7bfff0
> Stack overflow in unmanaged: IP: 0x8073bc8, fault addr: 0xbf7bff1c
> Stack overflow in unmanaged: IP: 0x8073bc8, fault addr: 0xbf7bfeac
> Stack overflow in unmanaged: IP: 0xb7eed44c, fault addr: 0xbf7bffec
> Stack overflow in unmanaged: IP: 0x8073bc8, fault addr: 0xbf7bfebc
> Stack overflow in unmanaged: IP: 0xb7dba573, fault addr: 0xbf7bee58
> Stack overflow in unmanaged: IP: 0x8073bc8, fault addr: 0xbf7bfecc
> Stack overflow in unmanaged: IP: 0x8073bc8, fault addr: 0xbf7bfecc
> Stack overflow in unmanaged: IP: 0x8073bc8, fault addr: 0xbf7bfe9c
> Stack overflow in unmanaged: IP: 0xb7de3944, fault addr: 0xbf7bffe8
> Stack overflow in unmanaged: IP: 0x8073bc8, fault addr: 0xbf7bfeac
> Stack overflow in unmanaged: IP: 0x81d7f5d, fault addr: 0xbf7bfe7c
> Stack overflow in unmanaged: IP: 0x81083ac, fault addr: 0xbf7bffec
> Stack overflow in unmanaged: IP: 0x81074fc, fault addr: 0xbf7bfffc
> Stack overflow in unmanaged: IP: 0xb7dba573, fault addr: 0xbf7bee38
> Stack overflow in unmanaged: IP: 0x8073bc8, fault addr: 0xbf7bfe9c
> Stack overflow in unmanaged: IP: 0xb7dba573, fault addr: 0xbf7bee38
> Stack overflow in unmanaged: IP: 0x8073bc8, fault addr: 0xbf7bfecc
> Stack overflow in unmanaged: IP: 0xb7de58dc, fault addr: 0xbf7bfff8
> Stack overflow in unmanaged: IP: 0xb7dba573, fault addr: 0xbf7bfe0c
>
> Unhandled Exception: System.StackOverflowException: The requested
> operation caused a stack overflow.
>  at (wrapper managed-to-native) System.MonoType:getFullName (bool,bool)
>  at System.MonoType.ToString () [0x00000]
>  at System.Exception.get_ClassName () [0x00000]
>  at System.Exception.ToString () [0x00000]
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20090507/7c3549e9/attachment.html 


More information about the Mono-devel-list mailing list