Skip to content

Commit 7114f4c

Browse files
authored
Merge pull request #1031 from Unity-Technologies/unity-master-boehm-hasenv-deadlock
Avoid deadlock during GC. (case 1077203)
2 parents 9292695 + 4d1bc5d commit 7114f4c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mono/metadata/boehm-gc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ void *pthread_get_stackaddr_np(pthread_t);
6060

6161
static gboolean gc_initialized = FALSE;
6262
static gboolean gc_strict_wbarriers = FALSE;
63+
static gboolean gc_dont_gc_env = FALSE;
6364
static mono_mutex_t mono_gc_lock;
6465

6566
typedef void (*GC_push_other_roots_proc)(void);
@@ -208,6 +209,9 @@ mono_gc_base_init (void)
208209
g_free (debug_opts);
209210
}
210211

212+
/* cache value rather than calling during collection since g_hasenv may take locks and can deadlock */
213+
gc_dont_gc_env = g_hasenv ("GC_DONT_GC");
214+
211215
GC_init ();
212216

213217
GC_set_warn_proc (mono_gc_warning);
@@ -1539,7 +1543,7 @@ mono_gc_is_moving (void)
15391543
gboolean
15401544
mono_gc_is_disabled (void)
15411545
{
1542-
if (GC_dont_gc || g_hasenv ("GC_DONT_GC"))
1546+
if (GC_dont_gc || gc_dont_gc_env)
15431547
return TRUE;
15441548
else
15451549
return FALSE;

0 commit comments

Comments
 (0)