From 1b16563e9f611f7d5e9607301f7115f12baf9183 Mon Sep 17 00:00:00 2001 From: Simon Cooksey Date: Mon, 22 Dec 2014 14:22:42 +0000 Subject: [PATCH] Fixed bug with re-running programs from xgdb This could be better implemented, but post-run the structure in reclaimUnreachableFunctions contains null ptrs, which causes segmentation faults. There's probably a better solution, but this works for now. --- lib/JIT.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/JIT.cpp b/lib/JIT.cpp index 9a0ed40..fb6814e 100644 --- a/lib/JIT.cpp +++ b/lib/JIT.cpp @@ -291,9 +291,11 @@ void JITImpl::reclaimUnreachableFunctions(JITCoreInfo &coreInfo) info->fastFuncValue }; for (LLVMValueRef f : functions) { - LLVMFreeMachineCodeForFunction(executionEngine, f); - LLVMReplaceAllUsesWith(f, LLVMGetUndef(LLVMTypeOf(f))); - LLVMDeleteFunction(f); + if(f){ + LLVMFreeMachineCodeForFunction(executionEngine, f); + LLVMReplaceAllUsesWith(f, LLVMGetUndef(LLVMTypeOf(f))); + LLVMDeleteFunction(f); + } } info->fastFunc = nullptr; info->func = nullptr;