Skip to content

build-exe stack-overflow on struct's self-referential fn field #3371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
seharris opened this issue Oct 3, 2019 · 0 comments
Closed

build-exe stack-overflow on struct's self-referential fn field #3371

seharris opened this issue Oct 3, 2019 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@seharris
Copy link

seharris commented Oct 3, 2019

Minimal example:

const Error = error {
    SomeError,
};
const A = struct {
    // Removing Error! fixes the problem in 0.5.0
    // Replacing A with, say, [256]i32, fixes the problem in both versions
    f: fn() Error!A,
};
fn f() Error!A {
    return Error.SomeError;
}
pub fn main() void {
    const a = A {
        .f = f, // undefined gives same result
    };
}

Compiling (via build-exe or run) causes the compiler to segfault.
Appears with Zig 0.5.0+edef35bb and 0.4.0+74abc5ad.
Tested on Linux x86-64.

gdb produces a huge repeating backtrace, so I'd assume infinite recursion:

#0  0x00007ffff1c5726e in resolve_llvm_types_fn_type(CodeGen*, ZigType*) [clone .part.0] ()
#1  0x00007ffff1c4a002 in type_resolve(CodeGen*, ZigType*, ResolveStatus) ()
#2  0x00007ffff1c571a4 in get_llvm_type(CodeGen*, ZigType*) ()
#3  0x00007ffff1c57ea8 in resolve_llvm_types_struct(CodeGen*, ZigType*, ResolveStatus, ZigType*) ()
#4  0x00007ffff1c4a9ba in type_resolve(CodeGen*, ZigType*, ResolveStatus) ()
#5  0x00007ffff1c571a4 in get_llvm_type(CodeGen*, ZigType*) ()
#6  0x00007ffff1c4b6f5 in type_resolve(CodeGen*, ZigType*, ResolveStatus) ()
#7  0x00007ffff1c49767 in type_resolve(CodeGen*, ZigType*, ResolveStatus) ()
#8  0x00007ffff1c571a4 in get_llvm_type(CodeGen*, ZigType*) ()
#9  0x00007ffff1c57347 in resolve_llvm_types_fn_type(CodeGen*, ZigType*) [clone .part.0] ()
#10 0x00007ffff1c4a002 in type_resolve(CodeGen*, ZigType*, ResolveStatus) ()
#11 0x00007ffff1c571a4 in get_llvm_type(CodeGen*, ZigType*) ()
#12 0x00007ffff1c57ea8 in resolve_llvm_types_struct(CodeGen*, ZigType*, ResolveStatus, ZigType*) ()
[snip]
@andrewrk andrewrk added this to the 0.6.0 milestone Oct 9, 2019
@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. labels Oct 9, 2019
@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Mar 31, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Aug 13, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
Vexu added a commit to Vexu/zig that referenced this issue Dec 28, 2022
Vexu added a commit to Vexu/zig that referenced this issue Dec 28, 2022
Vexu added a commit to Vexu/zig that referenced this issue Dec 28, 2022
Vexu added a commit to Vexu/zig that referenced this issue Dec 28, 2022
Vexu added a commit to Vexu/zig that referenced this issue Dec 28, 2022
Vexu added a commit to Vexu/zig that referenced this issue Dec 29, 2022
@andrewrk andrewrk modified the milestones: 0.12.0, 0.11.0 Dec 29, 2022
TUSF pushed a commit to TUSF/zig that referenced this issue May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

No branches or pull requests

2 participants