mirror of
https://github.com/ziglang/zig.git
synced 2024-11-15 08:33:06 +00:00
properly annotate nullability of ZigLLVMCreateDebugForwardDeclType
This bug manifested as a segfault in stage1 when calling this function. The C++ code looks like this: ```c++ entry->llvm_di_type = ZigLLVMCreateDebugForwardDeclType(g->dbuilder, ZigLLVMTag_DW_structure_type(), full_name, import ? ZigLLVMFileToScope(import->data.structure.root_struct->di_file) : nullptr, import ? import->data.structure.root_struct->di_file : nullptr, line); ``` There is actually no problem here - what happened is that because cross-language LTO was enabled between zig and c++ code, and because Zig annotated the file parameter (3rd line) as being non-null, the C++ code assumed that parameter could not be null, and eagerly dereferenced `import->...`, causing a segfault, since it was null. I verified that this commit fixed the problem and I also verified this hypothesis by disabling LTO and noticing that it indeed avoided the problem.
This commit is contained in:
parent
d31be31267
commit
cdb40936bd
@ -1734,8 +1734,8 @@ pub const DIBuilder = opaque {
|
||||
dib: *DIBuilder,
|
||||
tag: c_uint,
|
||||
name: [*:0]const u8,
|
||||
scope: *DIScope,
|
||||
file: *DIFile,
|
||||
scope: ?*DIScope,
|
||||
file: ?*DIFile,
|
||||
line: c_uint,
|
||||
) *DIType;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user