Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Feb 23 2016 10:19

    olebedev on master

    Update CI box (compare)

  • Feb 23 2016 10:17

    olebedev on master

    Update build badge at readme.md Add gitter badger Add command line tool to execut… and 7 more (compare)

  • Feb 18 2016 06:14
    olebedev commented #34
  • Feb 18 2016 05:00
    mirrr opened #34
  • Feb 16 2016 04:30
    olebedev assigned #33
  • Feb 16 2016 04:30
    olebedev opened #33
  • Jan 09 2016 09:38
    NikSmith commented #32
  • Jan 09 2016 07:00
    olebedev commented #32
  • Jan 08 2016 07:07
    olebedev labeled #32
  • Jan 08 2016 07:07
    olebedev labeled #32
  • Jan 08 2016 07:07
    olebedev commented #32
  • Jan 07 2016 20:43
    juggleru opened #32
  • Nov 25 2015 14:59
    olebedev commented #31
  • Nov 25 2015 14:59

    olebedev on v2

    Fix build on FreeBSD Merge pull request #31 from cry… (compare)

  • Nov 25 2015 14:59
    olebedev closed #31
  • Nov 25 2015 14:29
    cryptix opened #31
  • Nov 17 2015 10:23
    joeblew99 commented #30
  • Nov 17 2015 09:54
    olebedev closed #30
  • Nov 17 2015 09:54
    olebedev commented #30
  • Nov 17 2015 08:31

    olebedev on v2

    Add benchmarks (compare)

noctarius aka Christoph Engelbert
@noctarius
Awesome, started this morning but it crashes when making the syscall inside C.duk_debugger_attach, it's my first time going a bit deeper into CGO, therefore any help appreciated :D noctarius/go-duktape@b7007c4
Happy to help out with a PR in the end :)
Oleg Lebedev
@olebedev
:-)
noctarius aka Christoph Engelbert
@noctarius
@olebedev ok feeling stupid right now, finally had some time to look into the crash today ... it turned out debugging support wasn't yet enabled in the duk_config.h ;) that said, I use a c-trampoline to register go code as the transport handler which seems to work nicely. Need to test with a socket and the cli debugger now but buffers are passed back and forth and I just need to figure if it all works as expected
noctarius aka Christoph Engelbert
@noctarius
ok started making it into a pull request :P https://github.com/noctarius/go-duktape/tree/debugging-support
Clark Bynum
@sh3nan1gans
hi @olebedev - I'm running into an intermittent segfault with setTimeout. here's my program -
package main

import (
    "fmt"

    "gopkg.in/olebedev/go-duktape.v3"
)

const theFunc = `
    setTimeout(function() {
        print('in timeout callback');
        second();
    }, 2000);
    print('first step');
    while(true) {

    }
`

func main() {
    ctx := duktape.New()

    // Let's inject `setTimeout`, `setInterval`, `clearTimeout`,
    // `clearInterval` into global scope.
    ctx.PushTimers()

    ch := make(chan string)
    ctx.PushGlobalGoFunction("second", func(_ *duktape.Context) int {
        ch <- "second step"
        return 0
    })
    ctx.PevalString(theFunc)
    fmt.Println(<-ch)
}
output is -
first step
in timeout callback
fatal error: unexpected signal during runtime execution
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x40ba73d]

goroutine 19 [running]:
gopkg.in/olebedev/go-duktape%2ev3.(*Context).transmute(...)
    /Users/clarkbynum/Developer/golang/src/gopkg.in/olebedev/go-duktape.v3/duktape.go:38
gopkg.in/olebedev/go-duktape%2ev3.goFunctionCall(0x4304a50, 0xc00003c5f8)
    /Users/clarkbynum/Developer/golang/src/gopkg.in/olebedev/go-duktape.v3/duktape.go:152 +0x7d
gopkg.in/olebedev/go-duktape%2ev3._cgoexpwrap_9803a0f8a99f_goFunctionCall(0x4304a50, 0x2)
    _cgo_gotypes.go:3433 +0x2b
gopkg.in/olebedev/go-duktape%2ev3._Cfunc_duk_pcall(0x4304a50, 0x0, 0x0)
    _cgo_gotypes.go:2204 +0x4d
gopkg.in/olebedev/go-duktape%2ev3.(*Context).Pcall.func1(0x4304a50, 0x0, 0xc000000006)
    /Users/clarkbynum/Developer/golang/src/gopkg.in/olebedev/go-duktape.v3/api.go:773 +0x5e
gopkg.in/olebedev/go-duktape%2ev3.(*Context).Pcall(0xc00009a030, 0x0, 0x6)
    /Users/clarkbynum/Developer/golang/src/gopkg.in/olebedev/go-duktape.v3/api.go:773 +0x3d
gopkg.in/olebedev/go-duktape%2ev3.setTimeout.func1(0x409f400000000000, 0xc00009a030, 0x3ff0000000000000)
    /Users/clarkbynum/Developer/golang/src/gopkg.in/olebedev/go-duktape.v3/timers.go:55 +0x11b
created by gopkg.in/olebedev/go-duktape%2ev3.setTimeout
    /Users/clarkbynum/Developer/golang/src/gopkg.in/olebedev/go-duktape.v3/timers.go:43 +0xab
[signal SIGSEGV: segmentation violation code=0x1 addr=0x131ceb6b0 pc=0x40f0f4b]

runtime stack:
runtime.throw(0x4136990, 0x2a)
    /usr/local/Cellar/go/1.11.1/libexec/src/runtime/panic.go:608 +0x72
runtime.sigpanic()
    /usr/local/Cellar/go/1.11.1/libexec/src/runtime/signal_unix.go:374 +0x2f2

goroutine 1 [syscall]:
runtime.cgocall(0x40bd546, 0xc0000b9ea8, 0xc0000b9eb0)
    /usr/local/Cellar/go/1.11.1/libexec/src/runtime/cgocall.go:128 +0x5e fp=0xc0000b9e78 sp=0xc0000b9e40 pc=0x4004afe
gopkg.in/olebedev/go-duktape%2ev3._Cfunc__duk_peval_string(0x4304a50, 0x4318fb0, 0x0)
    _cgo_gotypes.go:644 +0x4d fp=0xc0000b9ea8 sp=0xc0000b9e78 pc=0x40b763d
gopkg.in/olebedev/go-duktape%2ev3.(*Context).PevalString.func1(0x4304a50, 0x4318fb0, 0x4318fb0)
    /Users/clarkbynum/Developer/golang/src/gopkg.in/olebedev/go-duktape.v3/api.go:880 +0x60 fp=0xc0000b9ee0 sp=0xc0000b9ea8 pc=0x40bbd30
gopkg.in/olebedev/go-duktape%2ev3.(*Context).PevalString(0xc00009a020, 0x4137a08, 0x7a, 0xc00008a210, 0x1)
    /Users/clarkbynum/Developer/golang/src/gopkg.in/olebedev/go-duktape.v3/api.go:880 +0x5f fp=0xc0000b9f20 sp=0xc0000b9ee0 pc=0x40b961f
main.main()
    /Users/clarkbynum/Developer/golang/src/test-go-duktape/main.go:32 +0xd7 fp=0xc0000b9f98 sp=0xc0000b9f20 pc=0x40bce77
runtime.main()
    /usr/local/Cellar/go/1.11.1/libexec/src/runtime/proc.go:201 +0x207 fp=0xc0000b9fe0 sp=0xc0000b9f98 pc=0x402b8f7
runtime.goexit()
    /usr/local/Cellar/go/1.11.1/libexec/src/runtime/asm_amd64.s:1333 +0x1 fp=0xc0000b9fe8 sp=0xc0000b9fe0 pc=0x40543f1

goroutine 19 [running]:
    goroutine running on other thread; stack unavailable
created by gopkg.in/olebedev/go-duktape%2ev3.setTimeout
    /Users/clarkbynum/Developer/golang/src/gopkg.in/olebedev/go-duktape.v3/timers.go:43 +0xab
is there some context that needs to be cleaned up/suspended when the setTimeout callback fires?
Clark Bynum
@sh3nan1gans
happy to help out with a PR just need a little guidance on this
Oleg Lebedev
@olebedev
Hi @sh3nan1gans,
It seems that the problem with the latest duktape source code update. Not sure about this, need to write and run some tests. Thanks for the report
Clark Bynum
@sh3nan1gans
ok, thank you. let me know if there's anything I can do to help out
Oleg Lebedev
@olebedev
You can try to run the same taste case against the previous commit from v3 branch. This would helps a lot.
Clark Bynum
@sh3nan1gans
ok, I tested with ccb656ba24c2a193e5650299767e2df1554725fd and here's what I got -
first step
in timeout callback
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4141690]

runtime stack:
runtime.throw(0x4193500, 0x2a)
    /usr/local/Cellar/go/1.11.1/libexec/src/runtime/panic.go:608 +0x72
runtime.sigpanic()
    /usr/local/Cellar/go/1.11.1/libexec/src/runtime/signal_unix.go:374 +0x2f2

goroutine 1 [syscall]:
runtime.cgocall(0x40bd0b0, 0xc0000bfea8, 0xc0000bfeb0)
    /usr/local/Cellar/go/1.11.1/libexec/src/runtime/cgocall.go:128 +0x5e fp=0xc0000bfe78 sp=0xc0000bfe40 pc=0x400450e
test-go-duktape/vendor/gopkg.in/olebedev/go-duktape%2ev3._Cfunc__duk_peval_string(0x44049f0, 0x44194a0, 0x0)
    _cgo_gotypes.go:706 +0x4d fp=0xc0000bfea8 sp=0xc0000bfe78 pc=0x40b704d
test-go-duktape/vendor/gopkg.in/olebedev/go-duktape%2ev3.(*Context).PevalString.func1(0x44049f0, 0x44194a0, 0x44194a0)
    /Users/clarkbynum/Developer/golang/src/test-go-duktape/vendor/gopkg.in/olebedev/go-duktape.v3/api.go:882 +0x60 fp=0xc0000bfee0 sp=0xc0000bfea8 pc=0x40bb740
test-go-duktape/vendor/gopkg.in/olebedev/go-duktape%2ev3.(*Context).PevalString(0xc0000a0020, 0x4194578, 0x7a, 0xc000090210, 0x1)
    /Users/clarkbynum/Developer/golang/src/test-go-duktape/vendor/gopkg.in/olebedev/go-duktape.v3/api.go:882 +0x5f fp=0xc0000bff20 sp=0xc0000bfee0 pc=0x40b902f
main.main()
    /Users/clarkbynum/Developer/golang/src/test-go-duktape/main.go:35 +0xd7 fp=0xc0000bff98 sp=0xc0000bff20 pc=0x40bc887
runtime.main()
    /usr/local/Cellar/go/1.11.1/libexec/src/runtime/proc.go:201 +0x207 fp=0xc0000bffe0 sp=0xc0000bff98 pc=0x402b307
runtime.goexit()
    /usr/local/Cellar/go/1.11.1/libexec/src/runtime/asm_amd64.s:1333 +0x1 fp=0xc0000bffe8 sp=0xc0000bffe0 pc=0x4053e01

goroutine 19 [chan send, locked to thread]:
main.main.func1(0xc0000a0038, 0x4419100)
    /Users/clarkbynum/Developer/golang/src/test-go-duktape/main.go:32 +0x36
test-go-duktape/vendor/gopkg.in/olebedev/go-duktape%2ev3.goFunctionCall(0x44049f0, 0xc00003c5f8)
    /Users/clarkbynum/Developer/golang/src/test-go-duktape/vendor/gopkg.in/olebedev/go-duktape.v3/duktape.go:156 +0xb6
test-go-duktape/vendor/gopkg.in/olebedev/go-duktape%2ev3._cgoexpwrap_25d7a6c4a830_goFunctionCall(0x44049f0, 0x0)
    _cgo_gotypes.go:3511 +0x2b
test-go-duktape/vendor/gopkg.in/olebedev/go-duktape%2ev3._Cfunc_duk_pcall(0x44049f0, 0x0, 0x0)
    _cgo_gotypes.go:2282 +0x4d
test-go-duktape/vendor/gopkg.in/olebedev/go-duktape%2ev3.(*Context).Pcall.func1(0x44049f0, 0x0, 0xc000000006)
    /Users/clarkbynum/Developer/golang/src/test-go-duktape/vendor/gopkg.in/olebedev/go-duktape.v3/api.go:776 +0x5e
test-go-duktape/vendor/gopkg.in/olebedev/go-duktape%2ev3.(*Context).Pcall(0xc0000a0030, 0x0, 0x6)
    /Users/clarkbynum/Developer/golang/src/test-go-duktape/vendor/gopkg.in/olebedev/go-duktape.v3/api.go:776 +0x3d
test-go-duktape/vendor/gopkg.in/olebedev/go-duktape%2ev3.setTimeout.func1(0x409f400000000000, 0xc0000a0030, 0x3ff0000000000000)
    /Users/clarkbynum/Developer/golang/src/test-go-duktape/vendor/gopkg.in/olebedev/go-duktape.v3/timers.go:55 +0x11b
created by test-go-duktape/vendor/gopkg.in/olebedev/go-duktape%2ev3.setTimeout
    /Users/clarkbynum/Developer/golang/src/test-go-duktape/vendor/gopkg.in/olebedev/go-duktape.v3/timers.go:43 +0xab
I also tested with v2 branch and got this -
first step
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x412e303]

runtime stack:
runtime.throw(0x4170190, 0x2a)
    /usr/local/Cellar/go/1.11.1/libexec/src/runtime/panic.go:608 +0x72
runtime.sigpanic()
    /usr/local/Cellar/go/1.11.1/libexec/src/runtime/signal_unix.go:374 +0x2f2

goroutine 5 [syscall]:
runtime.cgocall(0x40be960, 0xc000041f18, 0x29)
    /usr/local/Cellar/go/1.11.1/libexec/src/runtime/cgocall.go:128 +0x5e fp=0xc000041ee0 sp=0xc000041ea8 pc=0x40046ae
test-go-duktape/vendor/gopkg.in/olebedev/go-duktape%2ev2._Cfunc_duk_pcall(0x4704fd0, 0x0, 0x0)
    _cgo_gotypes.go:2175 +0x4d fp=0xc000041f18 sp=0xc000041ee0 pc=0x40b7cad
test-go-duktape/vendor/gopkg.in/olebedev/go-duktape%2ev2.(*Context).Pcall.func1(0x4704fd0, 0x0, 0xc000000006)
    /Users/clarkbynum/Developer/golang/src/test-go-duktape/vendor/gopkg.in/olebedev/go-duktape.v2/api.go:766 +0x5e fp=0xc000041f50 sp=0xc000041f18 pc=0x40bb5ee
test-go-duktape/vendor/gopkg.in/olebedev/go-duktape%2ev2.(*Context).Pcall(0xc00000e040, 0x0, 0x6)
    /Users/clarkbynum/Developer/golang/src/test-go-duktape/vendor/gopkg.in/olebedev/go-duktape.v2/api.go:766 +0x3d fp=0xc000041f78 sp=0xc000041f50 pc=0x40b8eed
test-go-duktape/vendor/gopkg.in/olebedev/go-duktape%2ev2.setTimeout.func1(0x409f400000000000, 0xc00000e040, 0x3ff0000000000000)
    /Users/clarkbynum/Developer/golang/src/test-go-duktape/vendor/gopkg.in/olebedev/go-duktape.v2/timers.go:55 +0x11b fp=0xc000041fc8 sp=0xc000041f78 pc=0x40bac8b
runtime.goexit()
    /usr/local/Cellar/go/1.11.1/libexec/src/runtime/asm_amd64.s:1333 +0x1 fp=0xc000041fd0 sp=0xc000041fc8 pc=0x4053fa1
created by test-go-duktape/vendor/gopkg.in/olebedev/go-duktape%2ev2.setTimeout
    /Users/clarkbynum/Developer/golang/src/test-go-duktape/vendor/gopkg.in/olebedev/go-duktape.v2/timers.go:43 +0xab

goroutine 1 [syscall]:
test-go-duktape/vendor/gopkg.in/olebedev/go-duktape%2ev2._Cfunc__duk_peval_string(0x4704fd0, 0x470d680, 0x0)
    _cgo_gotypes.go:642 +0x4d
test-go-duktape/vendor/gopkg.in/olebedev/go-duktape%2ev2.(*Context).PevalString.func2(0x4704fd0, 0x470d680, 0x470d680)
    /Users/clarkbynum/Developer/golang/src/test-go-duktape/vendor/gopkg.in/olebedev/go-duktape.v2/api.go:879 +0x60
test-go-duktape/vendor/gopkg.in/olebedev/go-duktape%2ev2.(*Context).PevalString(0xc00000e030, 0x4171208, 0x7a, 0x0, 0x0)
    /Users/clarkbynum/Developer/golang/src/test-go-duktape/vendor/gopkg.in/olebedev/go-duktape.v2/api.go:879 +0x88
main.main()
    /Users/clarkbynum/Developer/golang/src/test-go-duktape/main.go:35 +0xd7
Oleg Lebedev
@olebedev
Thanks for the afford. It’s really appreciated. Hopefully I’ll dig into it soon 🤞
Any/random ideas are really welcome too 😀
Clark Bynum
@sh3nan1gans
ok, thank you. It's worth noting that the crash only happens if the while loop is present. if I remove it setTimeout works great
Clark Bynum
@sh3nan1gans
after talking with my team we think that it is a duktape limitation and we'd need to implement some kind of event loop in order to pause execution after we get into the 'PevalString'. without that functionality the duktape context is getting corrupted when the setTimeout timer pops
Oleg Lebedev
@olebedev
This could be easily implemented at go side. As I remember, duktape doesn’t have interrupt, bwt
For now, there is a naive timers implementation, guided by the duktape’s author.
Clark Bynum
@sh3nan1gans
ok, my team is willing to help out if you have any ideas on how to implement it
we're kind of stumped on how to implement since duktape doesn't support interrupt
Clark Bynum
@sh3nan1gans
@olebedev - would the interrupt that the duktape debugger uses help with our use case? https://github.com/svaarala/duktape/blob/master/doc/execution.rst#debugger-support
Oleg Lebedev
@olebedev
Thanks for point me. I have to check it and apply corresponding changes to go bindings with regard to debugger.
The thing is that I have no time for this in nearest future.
noctarius aka Christoph Engelbert
@noctarius
hey folks, finally had time to make the debugger support a real thing ;)
@olebedev btw the windows build seems to fail since it cannot download go 1.9, tested the URL and it works, not sure what's wrong there
Oleg Lebedev
@olebedev
@noctarius 🎉 🎈 🥳
Thank you for the work! ill look at this asap
noctarius aka Christoph Engelbert
@noctarius
@olebedev well I need it myself :) working on a embedded system, therefore I need remote debugging :D
Oleg Lebedev
@olebedev

the windows build seems to fail since it cannot download go 1.9

@noctarius, FYI, the file is available for download.

noctarius aka Christoph Engelbert
@noctarius
I know it is, I tested it myself but the test claims different :D
Build started git clone -q --depth=5 https://github.com/olebedev/go-duktape.git C:\gopath\src\gopkg.in\olebedev\go-duktape.v3 git fetch -q origin +refs/pull/65/merge: git checkout -qf FETCH_HEAD Running Install scripts rmdir C:\go /s /q appveyor DownloadFile https://storage.googleapis.com/golang/go1.9.2.windows-%DUKTAPE_ARCH%.zip Error downloading remote file: One or more errors occurred. Inner Exception: Unable to connect to the remote server Command exited with code 2
Clark Bynum
@sh3nan1gans
@olebedev - would you accept a PR for an event loop implementation? https://github.com/svaarala/duktape/tree/master/examples/eventloop
Oleg Lebedev
@olebedev
@sh3nan1gans, sure, after review
noctarius aka Christoph Engelbert
@noctarius
Anyone ever managed to use Context::Error or Context::Throw? I get fatal error: exitsyscall: syscall frame is no longer valid.
Go version: 1.13.5
Otherwise I need a better way to throw errors (guess I could build a JS version to throw an error) ;)
@olebedev any idea?
Oleg Lebedev
@olebedev
Woops, sorry @noctarius, I have just noticed your messages. Nope, no idea wat's going on there.
If you would be interested in this project maintainance I could add you to the repo
jk-jeongkyun
@jeongkyun-oh
Hello, guys. I am here for asking a question. Is it possible to copy Context? I want to reuse the object since creating new one takes too much time. Thanks for your help in advance.
noctarius aka Christoph Engelbert
@noctarius

Hey @jeongkyun-oh I don't think there's a way to copy a context. The duktape issue tracker has multiple questions on cloning or copying a context (e.g. here svaarala/duktape#770). I think as long as duktape doesn't have support for it, there's nothing the wrapper could do.

One thing you may want to look into though is creating the appropriate JavaScript code, parse it into bytecode, dump and reload it. You still need to make sure you're able to supply your native functions though

@olebedev Same here, just realized your message. Seems like gitter isn't sending notifications anymore :D I'm happy to help out, not sure though, I'd be up to the point (yet) to fully take over maintenance, but certainly happy to help with managing it.
noctarius aka Christoph Engelbert
@noctarius
for the previous problem with error and throw, I'm not the only being hurt by that: golang/go#15639 (I actually ended up writing a method wrapper which throws an error inside of the JS codebase