Creating recursive debug info for functions could cause assertions.

This commit is contained in:
Christoffer Lerno
2026-01-07 23:50:56 +01:00
parent 527766310f
commit 8fa59cbb43
2 changed files with 12 additions and 7 deletions

View File

@@ -53,6 +53,7 @@
- Crash when doing a type property lookup for const inline enums in some cases #2717.
- Incorrect alignment on typedef and local variable debug info.
- Assert on optional-returning-function in a comma expression. #2722
- Creating recursive debug info for functions could cause assertions.
### Stdlib changes
- Add `ThreadPool` join function to wait for all threads to finish in the pool without destroying the threads.

View File

@@ -587,21 +587,25 @@ static LLVMMetadataRef llvm_debug_func_type(GenContext *c, Type *type)
if (type->backend_debug_type) return type->backend_debug_type;
// 3. Otherwise generate:
static LLVMMetadataRef *buffer = NULL;
vec_resize(buffer, 0);
vec_add(buffer, llvm_get_debug_type(c, typeget(sig->rtype)));
LLVMMetadataRef params[MAX_PARAMS + 1];
int index = 0;
params[index++] = llvm_get_debug_type(c, typeget(sig->rtype));
FOREACH(Decl *, param, sig->params)
{
vec_add(buffer, llvm_get_debug_type(c, param->type));
params[index++] = llvm_get_debug_type(c, param->type);
}
if (prototype->raw_variadic)
{
vec_add(buffer, LLVMDIBuilderCreateUnspecifiedType(c->debug.builder, "", 0));
params[index++] = LLVMDIBuilderCreateUnspecifiedType(c->debug.builder, "", 0);
}
// 4. We might be done again!
if (type->backend_debug_type) return type->backend_debug_type;
return LLVMDIBuilderCreateSubroutineType(c->debug.builder,
c->debug.file.debug_file,
buffer,
vec_size(buffer), 0);
params,
index, 0);
}