[Mono-bugs] [Bug 324361] Stack Overflow detection

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue May 12 12:28:07 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=324361

User kjambunathan.devel at gmail.com added comment
http://bugzilla.novell.com/show_bug.cgi?id=324361#c5





--- Comment #5 from Jambunathan Kalyanasundaram <kjambunathan.devel at gmail.com>  2009-05-12 10:28:06 MDT ---
Another simple test case for handling of StackOverflowProtection.


In the example down below, StackOverflowProtection should be caught righ within
the Main and handled there instead of being propagated to runtime.


Currently as I understand, mono_handle_exception_internal () while handling a
stack overflow, would ignore stack frames until it could safely acquire 64K of
stack space (refere free_stack variable) The implication is that for the
example down below the catch handler in Main () would be skipped. 


(Note: The example uses localloc only for inconvenience. localloc could be
replaced with a simple Recurse () and the above bug description would still be
vaild)

using System;

class T
{

        public unsafe static void Main ()
        {
            int size = 10 * 1024 * 1024; // FIXTHIS:

            while (size != 0) {
                Console.WriteLine ("Trying " + size + " bytes ...");

                try {
                        byte *buf = stackalloc byte[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;
            }
        }
}

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


More information about the mono-bugs mailing list