Skip to content

Commit 486f196

Browse files
committed
Make sure debuginfo won't dead lock during GC
1 parent 272a550 commit 486f196

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/debuginfo.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ class JuliaJITEventListener: public JITEventListener
194194
virtual void NotifyFunctionEmitted(const Function &F, void *Code,
195195
size_t Size, const EmittedFunctionDetails &Details)
196196
{
197+
int8_t gc_state = jl_gc_state_save_and_set(3);
197198
uv_rwlock_wrlock(&threadsafe);
199+
jl_gc_state_set(gc_state, 3);
198200
#if defined(_OS_WINDOWS_)
199201
create_PRUNTIME_FUNCTION((uint8_t*)Code, Size, F.getName(), (uint8_t*)Code, Size, NULL);
200202
#endif
@@ -205,7 +207,9 @@ class JuliaJITEventListener: public JITEventListener
205207

206208
std::map<size_t, FuncInfo, revcomp>& getMap()
207209
{
210+
int8_t gc_state = jl_gc_state_save_and_set(3);
208211
uv_rwlock_rdlock(&threadsafe);
212+
jl_gc_state_set(gc_state, 3);
209213
return info;
210214
}
211215
#endif // ifndef USE_MCJIT
@@ -218,7 +222,9 @@ class JuliaJITEventListener: public JITEventListener
218222
virtual void NotifyObjectEmitted(const ObjectImage &obj)
219223
#endif
220224
{
225+
int8_t gc_state = jl_gc_state_save_and_set(3);
221226
uv_rwlock_wrlock(&threadsafe);
227+
jl_gc_state_set(gc_state, 3);
222228
#ifdef LLVM36
223229
object::section_iterator Section = obj.section_begin();
224230
object::section_iterator EndSection = obj.section_end();
@@ -451,7 +457,9 @@ class JuliaJITEventListener: public JITEventListener
451457

452458
std::map<size_t, ObjectInfo, revcomp>& getObjectMap()
453459
{
460+
int8_t gc_state = jl_gc_state_save_and_set(3);
454461
uv_rwlock_rdlock(&threadsafe);
462+
jl_gc_state_set(gc_state, 3);
455463
return objectmap;
456464
}
457465
#endif // USE_MCJIT

0 commit comments

Comments
 (0)