aboutsummaryrefslogtreecommitdiff
path: root/src/Zcu/PerThread.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-07-09 21:03:36 -0400
committerGitHub <noreply@github.com>2024-07-09 21:03:36 -0400
commitb3b923e51f53330403bd99a224c19bc3f01005c4 (patch)
tree935255872a406744b2914f76d189dfc5025d9a90 /src/Zcu/PerThread.zig
parentc5283eb49b50c0d8b0d590b90f43523bed96e80a (diff)
parent1b34ae19beffcaa988de636c05264b3e9357a66f (diff)
downloadzig-b3b923e51f53330403bd99a224c19bc3f01005c4.tar.gz
zig-b3b923e51f53330403bd99a224c19bc3f01005c4.zip
Merge pull request #20561 from jacobly0/debug-segfaults
debug: prevent segfaults on linux
Diffstat (limited to 'src/Zcu/PerThread.zig')
-rw-r--r--src/Zcu/PerThread.zig19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Zcu/PerThread.zig b/src/Zcu/PerThread.zig
index a46f136a44..f638ffc538 100644
--- a/src/Zcu/PerThread.zig
+++ b/src/Zcu/PerThread.zig
@@ -2194,6 +2194,25 @@ fn processExportsInner(
gop.value_ptr.* = export_idx;
}
}
+
+ switch (exported) {
+ .decl_index => |idx| if (failed: {
+ const decl = zcu.declPtr(idx);
+ if (decl.analysis != .complete) break :failed true;
+ // Check if has owned function
+ if (!decl.owns_tv) break :failed false;
+ if (decl.typeOf(zcu).zigTypeTag(zcu) != .Fn) break :failed false;
+ // Check if owned function failed
+ const a = zcu.funcInfo(decl.val.toIntern()).analysis(&zcu.intern_pool);
+ break :failed a.state != .success;
+ }) {
+ // This `Decl` is failed, so was never sent to codegen.
+ // TODO: we should probably tell the backend to delete any old exports of this `Decl`?
+ return;
+ },
+ .value => {},
+ }
+
if (zcu.comp.bin_file) |lf| {
try zcu.handleUpdateExports(export_indices, lf.updateExports(pt, exported, export_indices));
} else if (zcu.llvm_object) |llvm_object| {