mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-07 14:24:43 +00:00
Merge pull request #13290 from Vexu/generic-deletion-mitigation
Mitigate generic deletion bug
This commit is contained in:
commit
c389f8800b
2 changed files with 12 additions and 32 deletions
|
|
@ -3367,6 +3367,8 @@ pub fn deinit(mod: *Module) void {
|
||||||
for (mod.import_table.keys()) |key| {
|
for (mod.import_table.keys()) |key| {
|
||||||
gpa.free(key);
|
gpa.free(key);
|
||||||
}
|
}
|
||||||
|
var failed_decls = mod.failed_decls;
|
||||||
|
mod.failed_decls = .{};
|
||||||
for (mod.import_table.values()) |value| {
|
for (mod.import_table.values()) |value| {
|
||||||
value.destroy(mod);
|
value.destroy(mod);
|
||||||
}
|
}
|
||||||
|
|
@ -3406,10 +3408,10 @@ pub fn deinit(mod: *Module) void {
|
||||||
mod.local_zir_cache.handle.close();
|
mod.local_zir_cache.handle.close();
|
||||||
mod.global_zir_cache.handle.close();
|
mod.global_zir_cache.handle.close();
|
||||||
|
|
||||||
for (mod.failed_decls.values()) |value| {
|
for (failed_decls.values()) |value| {
|
||||||
value.destroy(gpa);
|
value.destroy(gpa);
|
||||||
}
|
}
|
||||||
mod.failed_decls.deinit(gpa);
|
failed_decls.deinit(gpa);
|
||||||
|
|
||||||
if (mod.emit_h) |emit_h| {
|
if (mod.emit_h) |emit_h| {
|
||||||
for (emit_h.failed_decls.values()) |value| {
|
for (emit_h.failed_decls.values()) |value| {
|
||||||
|
|
@ -3482,6 +3484,14 @@ pub fn deinit(mod: *Module) void {
|
||||||
pub fn destroyDecl(mod: *Module, decl_index: Decl.Index) void {
|
pub fn destroyDecl(mod: *Module, decl_index: Decl.Index) void {
|
||||||
const gpa = mod.gpa;
|
const gpa = mod.gpa;
|
||||||
{
|
{
|
||||||
|
if (mod.failed_decls.contains(decl_index)) {
|
||||||
|
blk: {
|
||||||
|
const errs = mod.comp.getAllErrorsAlloc() catch break :blk;
|
||||||
|
for (errs.list) |err| Compilation.AllErrors.Message.renderToStdErr(err, .no_color);
|
||||||
|
}
|
||||||
|
// TODO restore test case triggering this panic
|
||||||
|
@panic("Zig compiler bug: attempted to destroy declaration with an attached error");
|
||||||
|
}
|
||||||
const decl = mod.declPtr(decl_index);
|
const decl = mod.declPtr(decl_index);
|
||||||
log.debug("destroy {*} ({s})", .{ decl, decl.name });
|
log.debug("destroy {*} ({s})", .{ decl, decl.name });
|
||||||
_ = mod.test_functions.swapRemove(decl_index);
|
_ = mod.test_functions.swapRemove(decl_index);
|
||||||
|
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
pub export fn entry1() void {
|
|
||||||
@setEvalBranchQuota(1001);
|
|
||||||
// Return type evaluation should inherit both the
|
|
||||||
// parent's branch quota and count meaning
|
|
||||||
// at least 2002 backwards branches are required.
|
|
||||||
comptime var i = 0;
|
|
||||||
inline while (i < 1000) : (i += 1) {}
|
|
||||||
_ = simple(10);
|
|
||||||
}
|
|
||||||
pub export fn entry2() void {
|
|
||||||
@setEvalBranchQuota(2001);
|
|
||||||
comptime var i = 0;
|
|
||||||
inline while (i < 1000) : (i += 1) {}
|
|
||||||
_ = simple(10);
|
|
||||||
}
|
|
||||||
fn simple(comptime n: usize) Type(n) {
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
fn Type(comptime n: usize) type {
|
|
||||||
if (n <= 1) return usize;
|
|
||||||
return Type(n - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// error
|
|
||||||
// backend=stage2
|
|
||||||
// target=native
|
|
||||||
//
|
|
||||||
// :21:16: error: evaluation exceeded 1001 backwards branches
|
|
||||||
// :21:16: note: use @setEvalBranchQuota() to raise the branch limit from 1001
|
|
||||||
// :16:34: note: called from here
|
|
||||||
Loading…
Add table
Reference in a new issue