Skip to content

Instantly share code, notes, and snippets.

@mikespook
Created May 6, 2013 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikespook/5525110 to your computer and use it in GitHub Desktop.
Save mikespook/5525110 to your computer and use it in GitHub Desktop.
SIGSEGV: segmentation violation PC=0xdeaddead signal arrived during cgo execution github.com/qiniu/py._Cfunc_PyImport_ExecCodeModule(0x304ca8, 0x2becc8, 0x304ca8) github.com/qiniu/py/_obj/_cgo_defun.c:547 +0x2f github.com/qiniu/py.ExecCodeModule(0x81012f8, 0x4, 0x2becc8, 0x0, 0x0, ...) github.com/qiniu/py/_obj/_cgo_gotypes.go:4120 +0x79 main.mai…
package main
import (
"fmt"
"time"
"github.com/qiniu/log"
"github.com/qiniu/py"
)
// -------------------------------------------------------------------
type FooModule struct {
}
func (r *FooModule) Py_bar(args *py.Tuple) (ret *py.Base, err error) {
var i int
var s string
err = py.Parse(args, &i, &s)
if err != nil {
return
}
fmt.Println("call foo.bar:", i, s)
return py.IncNone(), nil
}
func (r *FooModule) Py_bar2(args *py.Tuple) (ret *py.Base, err error) {
var i int
var s []string
err = py.ParseV(args, &i, &s)
if err != nil {
return
}
fmt.Println("call foo.bar2:", i, s)
return py.IncNone(), nil
}
// -------------------------------------------------------------------
const pyCode = `
import foo
foo.bar(1, 'Hello')
foo.bar2(1, 'Hello', 'world!')
`
func main() {
gomod, err := py.NewGoModule("foo", "", new(FooModule))
if err != nil {
log.Fatal("NewGoModule failed:", err)
}
defer gomod.Decref()
time.Sleep(2 * time.Minute)
code, err := py.Compile(pyCode, "", py.FileInput)
if err != nil {
log.Fatal("Compile failed:", err)
}
defer code.Decref()
mod, err := py.ExecCodeModule("test", code.Obj())
if err != nil {
log.Fatal("ExecCodeModule failed:", err)
}
defer mod.Decref()
}
// -------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment