//printf ("SFLDA1 %p\n", (char*)vtable->data + field->offset);
- if (domain->special_static_fields && (addr = g_hash_table_lookup (domain->special_static_fields, field)))
+ if (field->offset == -1) {
+ /* Special static */
+ g_assert (domain->special_static_fields);
+ mono_domain_lock (domain);
+ addr = g_hash_table_lookup (domain->special_static_fields, field);
+ mono_domain_unlock (domain);
addr = mono_get_special_static_data (GPOINTER_TO_UINT (addr));
- else
+ } else {
addr = (char*)mono_vtable_get_static_field_data (vtable) + field->offset;
-
+ }
return addr;
}
generic-static-methods.2.cs \
generic-null-call.2.cs \
generic-special.2.cs \
+ generic-special2.2.cs \
generic-exceptions.2.cs \
generic-virtual2.2.cs \
generic-valuetype-interface.2.cs \
generic-tailcall2.2.cs \
generic-array-exc.2.cs \
generic-special.2.cs \
+ generic-special2.2.cs \
generic-exceptions.2.cs \
generic-delegate2.2.cs \
generic-virtual2.2.cs \
--- /dev/null
+using System;
+using System.Reflection;
+using System.IO;
+using System.Collections.Generic;
+using System.Threading;
+
+internal class GenericType<T> {
+ [ThreadStatic]
+ internal static object static_var;
+
+ public static void AccessStaticVar ()
+ {
+ if (static_var != null && static_var.GetType () != typeof (List<T>))
+ throw new Exception ("Corrupted static var");
+ GenericType<T>.static_var = new List<T> ();
+ }
+}
+
+public static class Program {
+ private static bool stress;
+
+ /* Create a lot of static vars */
+ private static void CreateVTables ()
+ {
+ Type[] nullArgs = new Type[0];
+ Assembly ass = Assembly.GetAssembly (typeof (int));
+ foreach (Type type in ass.GetTypes ()) {
+ try {
+ Type inst = typeof (GenericType<>).MakeGenericType (type);
+ Activator.CreateInstance (inst);
+ } catch {
+ }
+ }
+ }
+
+ private static void StressStaticFieldAddr ()
+ {
+ while (stress) {
+ GenericType<object>.AccessStaticVar ();
+ }
+ }
+
+ public static void Main (string[] args)
+ {
+ Thread thread = new Thread (StressStaticFieldAddr);
+
+ stress = true;
+ thread.Start ();
+ CreateVTables ();
+ stress = false;
+
+ thread.Join ();
+ }
+}