Skip to content

Remote.Fetch() - unexpected signal during runtime execution #206

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
radeksimko opened this issue May 22, 2015 · 3 comments
Closed

Remote.Fetch() - unexpected signal during runtime execution #206

radeksimko opened this issue May 22, 2015 · 3 comments

Comments

@radeksimko
Copy link

Try running the following snippet of code:

package main

import (
    "fmt"
    "os"
    "path/filepath"

    "github.com/libgit2/git2go"
)

func main() {
    url := "https://github.com/radeksimko/vagrant-osx.git"
    path := filepath.Join(os.TempDir(), "test-git2go")
    cbs := getCallbacks()

    // fmt.Println("Using", path)

    if _, err := os.Stat(path); err == nil {
        repo, err := git.OpenRepository(path)
        if err != nil {
            fmt.Printf("Opening repository failed: %#v\n", err)
        }

        remote, err := repo.LookupRemote("origin")
        if err != nil {
            fmt.Printf("Remote lookup failed: %#v\n", err)
        }

        remote.SetCallbacks(cbs)

        fmt.Println("Fetching remote...")
        err = remote.Fetch([]string{}, nil, "")
        if err != nil {
            fmt.Printf("Fetching remote failed: %#v\n", err)
        }

        fmt.Println("Remotes fetched.")
    } else {
        repo, err := git.Clone(url, path, &git.CloneOptions{
            RemoteCallbacks: cbs,
        })
        if err != nil {
            fmt.Printf("Cloning repo failed: %#v\n", err)
        }

        fmt.Printf("Repo cloned: %#v\n", repo)
    }
}

func getCallbacks() *git.RemoteCallbacks {
    return &git.RemoteCallbacks{
        CredentialsCallback: func(url string, username_from_url string, allowed_types git.CredType) (git.ErrorCode, *git.Cred) {
            ret, cred := git.NewCredUserpassPlaintext("my-username", "**REDACTED**")
            return git.ErrorCode(ret), &cred
        },
    }
}

The commented-out fmt.Println is there intentionally. As it is, it's causing intermittent crashes, e.g.:

$ go run test.go 
Fetching remote...
fatal error: unexpected signal during runtime execution
[signal 0xb code=0x1 addr=0xb01dfacedebac1e pc=0x43b9cb6]

runtime stack:
runtime.gothrow(0x422e5d0, 0x2a)
    /usr/local/Cellar/go/1.4.2/libexec/src/runtime/panic.go:503 +0x8e
runtime.sigpanic()
    /usr/local/Cellar/go/1.4.2/libexec/src/runtime/sigpanic_unix.go:14 +0x5e

goroutine 1 [syscall, locked to thread]:
runtime.cgocall_errno(0x4005410, 0xc208067dd0, 0x0)
    /usr/local/Cellar/go/1.4.2/libexec/src/runtime/cgocall.go:130 +0xf5 fp=0xc208067db0 sp=0xc208067d88
github.com/libgit2/git2go._Cfunc_git_remote_fetch(0x5410470, 0xc208067e18, 0x0, 0x0, 0xc200000000)
    /Users/radeksimko/gopath/src/github.com/libgit2/git2go/:1710 +0x43 fp=0xc208067dd0 sp=0xc208067db0
github.com/libgit2/git2go.(*Remote).Fetch(0xc208054230, 0xc208067e88, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/radeksimko/gopath/src/github.com/libgit2/git2go/remote.go:628 +0x1ca fp=0xc208067e40 sp=0xc208067dd0
main.main()
    /var/workspace/test/test.go:32 +0x4fd fp=0xc208067f98 sp=0xc208067e40
runtime.main()
    /usr/local/Cellar/go/1.4.2/libexec/src/runtime/proc.go:63 +0xf3 fp=0xc208067fe0 sp=0xc208067f98
runtime.goexit()
    /usr/local/Cellar/go/1.4.2/libexec/src/runtime/asm_amd64.s:2232 +0x1 fp=0xc208067fe8 sp=0xc208067fe0

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /usr/local/Cellar/go/1.4.2/libexec/src/runtime/asm_amd64.s:2232 +0x1
exit status 2

but when the fmt.Println is uncommented (= it's printing that one line to stdout), it never crashes:

$ go run test.go 
Using /var/folders/dj/8v7ccb5n3838_mkbkfrxn59jr0_589/T/test-git2go
Fetching remote...
Remotes fetched.

It seems like a memory issue coming from the C code?

@carlosmn
Copy link
Member

It sounds like the moving-GC in 1.4 which forces us to implement handles ourselves. It should be fixed in master.

@michaeledgar
Copy link
Contributor

We're running into this as well. I don't think this is fixed in master - as #196 mentions, remote.go wasn't initially moved over to the new pointer indirection workaround.

@carlosmn
Copy link
Member

You're right, the network stuff did not get ported over, at the time it looked like it wasn't quite triggering it. I've been looking into porting that bit, but the clone test keeps causing quite odd errors in the allocator.

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

No branches or pull requests

3 participants