diff --git a/releasenotes.md b/releasenotes.md index 935499d0c..05abd69ee 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -71,6 +71,7 @@ - Assert not properly traced #1354. - Ordering issues with `$include` / `$exec` fixed #1302. - Issues with wincrt linking. +- Debug info with recursive canonical type usage could cause segfault. ### Stdlib changes diff --git a/src/compiler/llvm_codegen.c b/src/compiler/llvm_codegen.c index 1c8f3d3e2..a8ce4bbef 100644 --- a/src/compiler/llvm_codegen.c +++ b/src/compiler/llvm_codegen.c @@ -604,7 +604,7 @@ static void gencontext_verify_ir(GenContext *context) { if (*error) { - puts("IR integrity failure."); + eprintf("----------------------------------IR integrity failure:\n"); LLVMDumpModule(context->module); error_exit("Could not verify IR: %s", error); } @@ -1511,9 +1511,9 @@ void **llvm_gen(Module** modules, unsigned module_count) } for (unsigned i = 0; i < module_count; i++) { - GenContext *result = llvm_gen_module(modules[i], NULL); - if (!result) continue; - vec_add(gen_contexts, result); + GenContext *result = llvm_gen_module(modules[i], NULL); + if (!result) continue; + vec_add(gen_contexts, result); } if (compiler.build.benchmarking) { diff --git a/src/compiler/llvm_codegen_debug_info.c b/src/compiler/llvm_codegen_debug_info.c index 2b2a18da2..9a49d9bca 100644 --- a/src/compiler/llvm_codegen_debug_info.c +++ b/src/compiler/llvm_codegen_debug_info.c @@ -569,11 +569,9 @@ static LLVMMetadataRef llvm_debug_func_type(GenContext *c, Type *type) static inline LLVMMetadataRef llvm_get_debug_type_internal(GenContext *c, Type *type, LLVMMetadataRef scope) { - if (type->backend_debug_type) return type->backend_debug_type; - Type *canonical = type->canonical; - if (canonical != type) + if (type->backend_debug_type) { - return type->backend_debug_type = llvm_get_debug_type(c, canonical); + return type->backend_debug_type; } // Consider special handling of UTF8 arrays. switch (type->type_kind)