Bug 324299 (MONO81623) - Static .cctors and Main()
Summary: Static .cctors and Main()
Status: RESOLVED FIXED
Alias: MONO81623
Product: Mono: Debugger
Classification: Mono
Component: backend (show other bugs)
Version: 1.1
Hardware: Other Other
: P3 - Medium : Major
Target Milestone: ---
Assignee: Martin Baulig
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-14 23:19 UTC by Martin Baulig
Modified: 2007-10-05 12:34 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:38:37 UTC


---- Reported by martin@ximian.com 2007-05-14 16:19:56 MST ----

We currently have a problem with the way how the debugger breaks in Main:

If you're debugging an application where the class containing Main()
contains a static .cctor, you might run into problems.  This applies
especially if your application is using System.Configuration in that .cctor
or if the class has static fields which are using System.Configuration.

I'm currently working on a fix, but that'll require some larger changes in
the way how the debugger handles Main().

At the moment, the debugger gets a notification from the JIT before calling
mono_runtime_run_main() - this notification triggers a JIT compilation of
Main() and inserts a breakpoint on it.  This is neccessary because the
debugger may need to insert breakpoints when reaching Main().

Unfortunately, this is causing problems if that compilation needs to run
any static .cctors.

I'll change the code to not trigger the compilation but instead wait till
we reach Main() by normal flow of execution - don't know yet how exactly
this will be archived.



---- Additional Comments From martin@ximian.com 2007-05-14 16:25:45 MST ----

*** https://bugzilla.novell.com/show_bug.cgi?id=MONO81615 has been marked as a duplicate of this bug. ***



---- Additional Comments From martin@ximian.com 2007-05-14 16:26:28 MST ----

A simple test case is this:

======
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Configuration;

class X
{
        static X ()
        {
                Console.WriteLine ("TEST!");
                NameValueCollection config =
ConfigurationSettings.AppSettings;
                Console.WriteLine ("TEST #2");
        }

        static void Main ()
        {
                Console.WriteLine ("Hello World!");
        }
}
=====

This will crash when run inside mdb.


Unknown operating system unknown. Setting to default OS "Other".

Comment 1 Martin Baulig 2007-10-05 12:34:59 UTC
Fixed long ago.