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

linux.fork is broken on arm64 #3472

Open
PucklaJ opened this issue Apr 23, 2024 · 0 comments · May be fixed by #3476
Open

linux.fork is broken on arm64 #3472

PucklaJ opened this issue Apr 23, 2024 · 0 comments · May be fixed by #3476

Comments

@PucklaJ
Copy link

PucklaJ commented Apr 23, 2024

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

Useful information to add to a bug report:

Odin:    dev-2024-04:efc3f9916
OS:      Arch Linux ARM, Linux 6.7.9-1-MANJARO-ARM
CPU:     ARM64
RAM:     3862 MiB
Backend: LLVM 14.0.6

Expected Behavior

package main

import "core:sys/linux"
import "core:fmt"

main :: proc() {
    using linux

    pid, pid_err := fork()
    fmt.println("after fork")
    assert(pid_err == .NONE)

    if pid == 0 {
        argv := []cstring{
            "/usr/bin/env", nil,
        }
        envp := []cstring{
            "execy_env=1234", nil,
        }
        name := cstring("/usr/bin/env")

        fmt.println("in child")

        e_err := execve(name, raw_data(argv), raw_data(envp))
        fmt.eprintln("unreachable")
        assert(e_err == .NONE)
    } else {
        fmt.println("in parent")
        status: i32
        w_err := syscall(SYS_wait4, Pid(-1), &status, cast(u32)0, cast(rawptr) nil)
        assert(w_err >= 0)

        fmt.printfln("status: {}", status)
    }
}

This program should work, but it sometimes does not.

Current Behavior

This is the syscall for fork on arm64:

syscall(SYS_clone, Signal.SIGCHLD)

The current behaviour is that it sometimes fails to fork.

The clone syscall is documented as follows:

220	clone	man/ cs/	DC	unsigned long	unsigned long	int*	   int*	unsigned long

The syscall should set all parameters.

Failure Information (for bugs)

Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. step 1
  2. step 2
  3. you get it...

Failure Logs

Please include any relevant log snippets or files here.

@PucklaJ PucklaJ linked a pull request Apr 24, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant