This is mostly a rebased commit history of #62, plus the addition of a new jit package to allow compiling and loading Go files/packages/text, and recursively resolving their dependencies.
This allows users to build and load arbitrary Go files with any number of imports automatically.
The jit package and tests are early on in the commit history to demonstrate the purpose of each subsequent commit in fixing specific tests.
Some tests are still failing randomly (e.g. TestJitCGoCall, TestStackSplit and TestJitPanicRecoveryStackTrace) due to some outstanding bugs in goloader which still need to be fixed.
Specifically:
Things which trigger stack copies/stack splits while a dynamically loaded function is running can cause an incomplete stack unwinding (fatal error: traceback did not unwind completely) , possibly because the g's stack pointer was incorrectly incremented twice somewhere, so the unwinding doesn't ever reach the stack start. Unclear whether this is a TLS relocation issue or something else?
TestJitCGoCall sometimes gets fatal error: unknown caller pc during a call to runtime.morestack():
This is mostly a rebased commit history of #62, plus the addition of a new
jit
package to allow compiling and loading Go files/packages/text, and recursively resolving their dependencies.This allows users to build and load arbitrary Go files with any number of imports automatically.
The
jit
package and tests are early on in the commit history to demonstrate the purpose of each subsequent commit in fixing specific tests.Some tests are still failing randomly (e.g.
TestJitCGoCall
,TestStackSplit
andTestJitPanicRecoveryStackTrace
) due to some outstanding bugs in goloader which still need to be fixed.Specifically:
fatal error: traceback did not unwind completely
) , possibly because theg
's stack pointer was incorrectly incremented twice somewhere, so the unwinding doesn't ever reach the stack start. Unclear whether this is a TLS relocation issue or something else?TestJitCGoCall
sometimes getsfatal error: unknown caller pc
during a call toruntime.morestack()
:runtime stack: runtime.throw({0x80b9d1?, 0xc0002c0240?}) /usr/local/go/src/runtime/panic.go:1047 +0x5d fp=0x7f5f277fd790 sp=0x7f5f277fd760 pc=0x439e7d runtime.gentraceback(0x0?, 0x0?, 0xe?, 0xc00058dfd8?, 0x0, 0x0, 0x7fffffff, 0x83c5e0, 0x0?, 0x0) /usr/local/go/src/runtime/traceback.go:258 +0x1cf7 fp=0x7f5f277fdb00 sp=0x7f5f277fd790 pc=0x4616f7 runtime.copystack(0xc001e99860, 0x800000002?) /usr/local/go/src/runtime/stack.go:932 +0x2f5 fp=0x7f5f277fdcb8 sp=0x7f5f277fdb00 pc=0x453bf5 runtime.newstack() /usr/local/go/src/runtime/stack.go:1112 +0x497 fp=0x7f5f277fde70 sp=0x7f5f277fdcb8 pc=0x454177 runtime.morestack() /usr/local/go/src/runtime/asm_amd64.s:570 +0x8b fp=0x7f5f277fde78 sp=0x7f5f277fde70 pc=0x46c34b
goroutine 170 [copystack]: crypto/internal/nistec/fiat.p384ToMontgomery(0xc00a33ca68, 0xc00a33c8e8) $GOROOT/src/crypto/internal/nistec/fiat/p384_fiat64.go:2116 +0x1b2b fp=0xc00a33c8d8 sp=0xc00a33c8d0 pc=0x40b8c0e3 crypto/internal/nistec/fiat.(P384Element).SetBytes(0xc00a33ca68, {0xc000275e29?, 0xb?, 0xc006f79aa0?}) $GOROOT/src/crypto/internal/nistec/fiat/p384.go:96 +0x179 fp=0xc00a33c958 sp=0xc00a33c8d8 pc=0x40b8a0f9 crypto/internal/nistec.(P384Point).SetBytes(0xc004bb0888, {0xc000275e28, 0xc00058cbc8?, 0x122}) $GOROOT/src/crypto/internal/nistec/p384.go:69 +0x1f6 fp=0xc00a33cb70 sp=0xc00a33c958 pc=0x40b8f1d6 crypto/elliptic.(nistCurve[go.shape.uint8_0]).Unmarshal(0x40d7bc00, {0xc000275e28, 0x61, 0x122}) $GOROOT/src/crypto/elliptic/nistec.go:257 +0x84 fp=0xc00a33cbd0 sp=0xc00a33cb70 pc=0x40b7cdfc crypto/elliptic.(nistCurve[crypto/internal/nistec.P384Point]).Unmarshal({0xc000275e28?, 0x40d7bc00?, 0x40b61498?})