Skip to content
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

LLVM assertion in ChildProcess.spawnPosix #6682

Open
mproved opened this issue Oct 14, 2020 · 3 comments
Open

LLVM assertion in ChildProcess.spawnPosix #6682

mproved opened this issue Oct 14, 2020 · 3 comments
Labels
bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@mproved
Copy link
Contributor

mproved commented Oct 14, 2020

const std = @import("std");

pub const io_mode = .evented;

pub fn main() !void {
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};

    var array = &[_][]const u8{ "java", "-Xmx2G", "-jar", "server.jar", "nogui" };

    var child_process = try std.ChildProcess.init(array, &gpa.allocator);
    child_process.cwd = "auth";
    child_process.stdin_behavior = std.ChildProcess.StdIo.Pipe;
    child_process.stdout_behavior = std.ChildProcess.StdIo.Pipe;
    child_process.stderr_behavior = std.ChildProcess.StdIo.Pipe;

    var process_frame = async child_process.spawnAndWait();

    // std.time.sleep(1_000_000_000 * 40);

    _ = try child_process.stdin.?.write("stop\n");

    // var term_status = await process_frame;

    // std.debug.print("{}", .{term_status});
}
broken LLVM module found: Basic Block in function 'std.child_process.ChildProcess.spawnPosix' does not have terminator! label %OkResume
Instruction does not dominate all uses!
  %28 = load { %std.child_process.Term, i16 }*, { %std.child_process.Term, i16 }** %6, align 8, !dbg !23024
  %41 = bitcast { %std.child_process.Term, i16 }* %28 to i8*, !dbg !23024

This is a bug in the Zig compiler.
Unable to dump stack trace: debug info stripped
Aborted (core dumped)
@Vexu Vexu added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. labels Oct 15, 2020
@Vexu Vexu added this to the 0.8.0 milestone Oct 15, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@elerch
Copy link
Contributor

elerch commented Jan 8, 2021

I ran across a similar issue and in my reduction narrowed it down to working with std.ChildProcess under evented io. Commenting line 4 (pub const io_mode = .evented) in the code below will compile successfully. Compiling as is will produce the error on versions 0.6.0 -> current master 31802c6

const std = @import("std");
const allocator = std.heap.page_allocator;

pub const io_mode = .evented;

pub fn main() !void {
    const process = try std.ChildProcess.init(&[_][]const u8{ "zig", "version" }, allocator);
    defer process.deinit();
    try process.spawn();
}

@17dec
Copy link

17dec commented Apr 3, 2021

This appears to be the result of #5728. forkChildErrReport() is marked as noreturn but uses async calling convention in evented io_mode due to writeIntFd()'s use of File.write().

Workaround is to add a 'nosuspend' before the last line in writeIntFd().

@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
@chr1sniessl
Copy link

I'm currently trying to use the workaround for spawnPosix by adding nosuspend, however I'm still seeing a similar issue on my machine:

broken LLVM module found: Instruction does not dominate all uses!
%28 = load { %std.child_process.Term, i16 }, { %std.child_process.Term, i16 }** %6, align 4, !dbg !80716
%41 = bitcast { %std.child_process.Term, i16 } %28 to i8*, !dbg !80716

This is a bug in the Zig compiler.thread 2209 panic:
Unable to dump stack trace: debug info stripped

My implementation of the workaround is:

fn writeIntFd(fd: i32, value: ErrInt) !void {
    const file = File{
        .handle = fd,
        .capable_io_mode = .blocking,
        .intended_io_mode = .blocking,
    };
    nosuspend file.writer().writeIntNative(u64, @intcast(u64, value)) catch return error.SystemResources;
}

This is using zig-bootstrap to generate the zig binary for aarch64-linux-musl cortex_a72.

@Vexu Vexu removed the stage1 The process of building from source via WebAssembly and the C backend. label Dec 8, 2022
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
Projects
None yet
Development

No branches or pull requests

6 participants