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

Fatal javascript OOM in GC during deserialization #347

Open
i5heu opened this issue Oct 27, 2022 · 2 comments
Open

Fatal javascript OOM in GC during deserialization #347

i5heu opened this issue Oct 27, 2022 · 2 comments

Comments

@i5heu
Copy link

i5heu commented Oct 27, 2022

Hi,

if I try to run about 100 concurrent v8 instances, this error occurs.
It also occurs eventually if I run 10 concurrent instances multiple times.

Here is the code to reproduce:
https://github.com/i5heu/distribution-game/tree/e8e7a5146a1bad3c132d48c0744a410ecdc15421

run in cloned repository on commit level e8e7a5146a1bad3c132d48c0744a410ecdc15421 :

npm i
npm run build
cd backend
go run .

go with your browser to localhost:3333 and click on "Run" on the right half of the screen.

Error log:


<--- Last few GCs --->


<--- JS stacktrace --->


#
# Fatal javascript OOM in GC during deserialization
#


<--- Last few GCs --->


<--- JS stacktrace --->


#
# Fatal javascript OOM in GC during deserialization
#


<--- Last few GCs --->


<--- JS stacktrace --->


#
# Fatal javascript OOM in GC during deserialization
#


<--- Last few GCs --->


<--- JS stacktrace --->


#
# Fatal javascript OOM in GC during deserialization
#


<--- Last few GCs --->


<--- JS stacktrace --->


#
# Fatal javascript OOM in GC during deserialization
#


<--- Last few GCs --->


<--- JS stacktrace --->


#
# Fatal javascript OOM in GC during deserialization
#


<--- Last few GCs --->


<--- JS stacktrace --->


#
# Fatal javascript OOM in GC during deserialization
#


<--- Last few GCs --->


<--- JS stacktrace --->


#
# Fatal javascript OOM in GC during deserialization
#

SIGTRAP: trace trap
PC=0x12bfa8e m=13 sigcode=128
signal arrived during cgo execution

goroutine 643 [syscall]:
runtime.cgocall(0xa58d50, 0xc0001d1ef0)
        /usr/local/go/src/runtime/cgocall.go:158 +0x5c fp=0xc0001d1ec8 sp=0xc0001d1e90 pc=0x80295c
rogchap.com/v8go._Cfunc_NewIsolate()
        _cgo_gotypes.go:732 +0x49 fp=0xc0001d1ef0 sp=0xc0001d1ec8 pc=0x8eefa9
rogchap.com/v8go.NewIsolate()
        /root/go/pkg/mod/rogchap.com/[email protected]/isolate.go:59 +0x3c fp=0xc0001d1f28 sp=0xc0001d1ef0 pc=0x8f153c
main/agent.New({0x0?, 0x0?}, {0xc000410660, 0x13})
        /root/distribution-game/backend/agent/agent.go:11 +0x2d fp=0xc0001d1fb0 sp=0xc0001d1f28 pc=0x8f44ad
main.runSimulator.func3()
        /root/distribution-game/backend/main.go:67 +0x32 fp=0xc0001d1fe0 sp=0xc0001d1fb0 pc=0xa581b2
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0001d1fe8 sp=0xc0001d1fe0 pc=0x863c61
created by main.runSimulator
        /root/distribution-game/backend/main.go:67 +0x2f4

goroutine 1 [IO wait]:
runtime.gopark(0x200000003?, 0xc0000061a0?, 0x0?, 0x0?, 0xc000125be0?)
        /usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc000125b70 sp=0xc000125b50 pc=0x837016
runtime.netpollblock(0xc000125bc0?, 0x2?, 0x0?)
        /usr/local/go/src/runtime/netpoll.go:526 +0xf7 fp=0xc000125ba8 sp=0xc000125b70 pc=0x82fb37
internal/poll.runtime_pollWait(0x7fae627c37c8, 0x72)
        /usr/local/go/src/runtime/netpoll.go:305 +0x89 fp=0xc000125bc8 sp=0xc000125ba8 pc=0x85ea89
internal/poll.(*pollDesc).wait(0xc000150000?, 0x6?, 0x0)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:84 +0x32 fp=0xc000125bf0 sp=0xc000125bc8 pc=0x8ad2b2
internal/poll.(*pollDesc).waitRead(...)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:89
internal/poll.(*FD).Accept(0xc000150000)
        /usr/local/go/src/internal/poll/fd_unix.go:614 +0x234 fp=0xc000125c88 sp=0xc000125bf0 pc=0x8ae774
net.(*netFD).accept(0xc000150000)
        /usr/local/go/src/net/fd_unix.go:172 +0x35 fp=0xc000125d40 sp=0xc000125c88 pc=0x97e8f5
net.(*TCPListener).accept(0xc000012150)
        /usr/local/go/src/net/tcpsock_posix.go:142 +0x28 fp=0xc000125d70 sp=0xc000125d40 pc=0x990628
net.(*TCPListener).Accept(0xc000012150)
        /usr/local/go/src/net/tcpsock.go:288 +0x3d fp=0xc000125da0 sp=0xc000125d70 pc=0x98f97d
net/http.(*onceCloseListener).Accept(0xc000000aa0?)
        <autogenerated>:1 +0x2a fp=0xc000125db8 sp=0xc000125da0 pc=0xa4854a
net/http.(*Server).Serve(0xc00014e000, {0x196b060, 0xc000012150})
        /usr/local/go/src/net/http/server.go:3070 +0x385 fp=0xc000125ee8 sp=0xc000125db8 pc=0xa38dc5
net/http.(*Server).ListenAndServe(0xc00014e000)
        /usr/local/go/src/net/http/server.go:2999 +0x7d fp=0xc000125f18 sp=0xc000125ee8 pc=0xa389fd
net/http.ListenAndServe(...)
        /usr/local/go/src/net/http/server.go:3255
main.main()
        /root/distribution-game/backend/main.go:23 +0xd7 fp=0xc000125f80 sp=0xc000125f18 pc=0xa57af7
runtime.main()
        /usr/local/go/src/runtime/proc.go:250 +0x212 fp=0xc000125fe0 sp=0xc000125f80 pc=0x836c52
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000125fe8 sp=0xc000125fe0 pc=0x863c61

goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc000050fb0 sp=0xc000050f90 pc=0x837016
runtime.goparkunlock(...)
        /usr/local/go/src/runtime/proc.go:369
runtime.forcegchelper()
        /usr/local/go/src/runtime/proc.go:302 +0xad fp=0xc000050fe0 sp=0xc000050fb0 pc=0x836ead
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000050fe8 sp=0xc000050fe0 pc=0x863c61
created by runtime.init.6
        /usr/local/go/src/runtime/proc.go:290 +0x25

goroutine 3 [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc000051790 sp=0xc000051770 pc=0x837016
runtime.goparkunlock(...)
        /usr/local/go/src/runtime/proc.go:369
runtime.bgsweep(0x0?)
        /usr/local/go/src/runtime/mgcsweep.go:278 +0x8e fp=0xc0000517c8 sp=0xc000051790 pc=0x8237ce
runtime.gcenable.func1()
        /usr/local/go/src/runtime/mgc.go:178 +0x26 fp=0xc0000517e0 sp=0xc0000517c8 pc=0x818686
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0000517e8 sp=0xc0000517e0 pc=0x863c61
created by runtime.gcenable
        /usr/local/go/src/runtime/mgc.go:178 +0x6b

goroutine 4 [GC scavenge wait]:
runtime.gopark(0xc000026070?, 0x1967a30?, 0x1?, 0x0?, 0x0?)
        /usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc000051f70 sp=0xc000051f50 pc=0x837016
runtime.goparkunlock(...)
        /usr/local/go/src/runtime/proc.go:369
runtime.(*scavengerState).park(0x2675d20)
        /usr/local/go/src/runtime/mgcscavenge.go:389 +0x53 fp=0xc000051fa0 sp=0xc000051f70 pc=0x821873
runtime.bgscavenge(0x0?)
        /usr/local/go/src/runtime/mgcscavenge.go:617 +0x45 fp=0xc000051fc8 sp=0xc000051fa0 pc=0x821e45
runtime.gcenable.func2()
        /usr/local/go/src/runtime/mgc.go:179 +0x26 fp=0xc000051fe0 sp=0xc000051fc8 pc=0x818626
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000051fe8 sp=0xc000051fe0 pc=0x863c61
created by runtime.gcenable
        /usr/local/go/src/runtime/mgc.go:179 +0xaa

goroutine 5 [finalizer wait]:
runtime.gopark(0x2676480?, 0xc000007860?, 0x0?, 0x0?, 0xc000050770?)
        /usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc000050628 sp=0xc000050608 pc=0x837016
runtime.goparkunlock(...)
        /usr/local/go/src/runtime/proc.go:369
runtime.runfinq()
        /usr/local/go/src/runtime/mfinal.go:180 +0x10f fp=0xc0000507e0 sp=0xc000050628 pc=0x81778f
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0000507e8 sp=0xc0000507e0 pc=0x863c61
created by runtime.createfing
        /usr/local/go/src/runtime/mfinal.go:157 +0x45

goroutine 6 [IO wait]:
runtime.gopark(0x2?, 0xb?, 0x0?, 0x0?, 0x4?)
        /usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc0001217b8 sp=0xc000121798 pc=0x837016
runtime.netpollblock(0x898485?, 0x2641510?, 0x0?)
        /usr/local/go/src/runtime/netpoll.go:526 +0xf7 fp=0xc0001217f0 sp=0xc0001217b8 pc=0x82fb37
internal/poll.runtime_pollWait(0x7fae627c36d8, 0x72)
        /usr/local/go/src/runtime/netpoll.go:305 +0x89 fp=0xc000121810 sp=0xc0001217f0 pc=0x85ea89
internal/poll.(*pollDesc).wait(0xc000150080?, 0xc000166000?, 0x0)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:84 +0x32 fp=0xc000121838 sp=0xc000121810 pc=0x8ad2b2
internal/poll.(*pollDesc).waitRead(...)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:89
internal/poll.(*FD).Read(0xc000150080, {0xc000166000, 0x1000, 0x1000})
        /usr/local/go/src/internal/poll/fd_unix.go:167 +0x25a fp=0xc0001218b8 sp=0xc000121838 pc=0x8ade5a
net.(*netFD).Read(0xc000150080, {0xc000166000?, 0x8ad7a6?, 0x1?})
        /usr/local/go/src/net/fd_posix.go:55 +0x29 fp=0xc000121900 sp=0xc0001218b8 pc=0x97d789
net.(*conn).Read(0xc000014038, {0xc000166000?, 0x0?, 0x0?})
        /usr/local/go/src/net/net.go:183 +0x45 fp=0xc000121948 sp=0xc000121900 pc=0x988a05
net/http.(*connReader).Read(0xc00007cf30, {0xc000166000, 0x1000, 0x1000})
        /usr/local/go/src/net/http/server.go:786 +0x171 fp=0xc000121998 sp=0xc000121948 pc=0xa2ead1
bufio.(*Reader).fill(0xc00002e360)
        /usr/local/go/src/bufio/bufio.go:106 +0xff fp=0xc0001219d0 sp=0xc000121998 pc=0x9e173f
bufio.(*Reader).Peek(0xc00002e360, 0x4)
        /usr/local/go/src/bufio/bufio.go:144 +0x5d fp=0xc0001219f0 sp=0xc0001219d0 pc=0x9e189d
net/http.(*conn).readRequest(0xc000000aa0, {0x196b5b8, 0xc000078240})
        /usr/local/go/src/net/http/server.go:991 +0x1f8 fp=0xc000121b78 sp=0xc0001219f0 pc=0xa30018
net/http.(*conn).serve(0xc000000aa0, {0x196b660, 0xc00007ce40})
        /usr/local/go/src/net/http/server.go:1916 +0x345 fp=0xc000121fb8 sp=0xc000121b78 pc=0xa34525
net/http.(*Server).Serve.func3()
        /usr/local/go/src/net/http/server.go:3102 +0x2e fp=0xc000121fe0 sp=0xc000121fb8 pc=0xa391ae
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000121fe8 sp=0xc000121fe0 pc=0x863c61
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:3102 +0x4db

goroutine 648 [syscall]:
runtime.cgocall(0xa58d50, 0xc0001d3ef0)
        /usr/local/go/src/runtime/cgocall.go:158 +0x5c fp=0xc0001d3ec8 sp=0xc0001d3e90 pc=0x80295c
rogchap.com/v8go._Cfunc_NewIsolate()
        _cgo_gotypes.go:732 +0x49 fp=0xc0001d3ef0 sp=0xc0001d3ec8 pc=0x8eefa9
rogchap.com/v8go.NewIsolate()
        /root/go/pkg/mod/rogchap.com/[email protected]/isolate.go:59 +0x3c fp=0xc0001d3f28 sp=0xc0001d3ef0 pc=0x8f153c
main/agent.New({0x0?, 0x0?}, {0xc000410660, 0x13})
        /root/distribution-game/backend/agent/agent.go:11 +0x2d fp=0xc0001d3fb0 sp=0xc0001d3f28 pc=0x8f44ad
main.runSimulator.func3()
        /root/distribution-game/backend/main.go:67 +0x32 fp=0xc0001d3fe0 sp=0xc0001d3fb0 pc=0xa581b2
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0001d3fe8 sp=0xc0001d3fe0 pc=0x863c61
created by main.runSimulator
        /root/distribution-game/backend/main.go:67 +0x2f4

goroutine 353 [syscall]:
runtime.cgocall(0xa58d50, 0xc0001d16f0)
        /usr/local/go/src/runtime/cgocall.go:158 +0x5c fp=0xc0001d16c8 sp=0xc0001d1690 pc=0x80295c
rogchap.com/v8go._Cfunc_NewIsolate()
        _cgo_gotypes.go:732 +0x49 fp=0xc0001d16f0 sp=0xc0001d16c8 pc=0x8eefa9
rogchap.com/v8go.NewIsolate()
        /root/go/pkg/mod/rogchap.com/[email protected]/isolate.go:59 +0x3c fp=0xc0001d1728 sp=0xc0001d16f0 pc=0x8f153c
main/agent.New({0x0?, 0x0?}, {0xc000410660, 0x13})
        /root/distribution-game/backend/agent/agent.go:11 +0x2d fp=0xc0001d17b0 sp=0xc0001d1728 pc=0x8f44ad
main.runSimulator.func3()
        /root/distribution-game/backend/main.go:67 +0x32 fp=0xc0001d17e0 sp=0xc0001d17b0 pc=0xa581b2
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0001d17e8 sp=0xc0001d17e0 pc=0x863c61
created by main.runSimulator
        /root/distribution-game/backend/main.go:67 +0x2f4

goroutine 642 [syscall]:
runtime.cgocall(0xa58d50, 0xc0003c36f0)
        /usr/local/go/src/runtime/cgocall.go:158 +0x5c fp=0xc0003c36c8 sp=0xc0003c3690 pc=0x80295c
rogchap.com/v8go._Cfunc_NewIsolate()
        _cgo_gotypes.go:732 +0x49 fp=0xc0003c36f0 sp=0xc0003c36c8 pc=0x8eefa9
rogchap.com/v8go.NewIsolate()
        /root/go/pkg/mod/rogchap.com/[email protected]/isolate.go:59 +0x3c fp=0xc0003c3728 sp=0xc0003c36f0 pc=0x8f153c
main/agent.New({0x19690a0?, 0xc0003c37d0?}, {0xc000410660, 0x13})
        /root/distribution-game/backend/agent/agent.go:11 +0x2d fp=0xc0003c37b0 sp=0xc0003c3728 pc=0x8f44ad
main.runSimulator.func3()
        /root/distribution-game/backend/main.go:67 +0x32 fp=0xc0003c37e0 sp=0xc0003c37b0 pc=0xa581b2
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0003c37e8 sp=0xc0003c37e0 pc=0x863c61
created by main.runSimulator
        /root/distribution-game/backend/main.go:67 +0x2f4

goroutine 644 [syscall]:
runtime.cgocall(0xa58d50, 0xc0001d26f0)
        /usr/local/go/src/runtime/cgocall.go:158 +0x5c fp=0xc0001d26c8 sp=0xc0001d2690 pc=0x80295c
rogchap.com/v8go._Cfunc_NewIsolate()
        _cgo_gotypes.go:732 +0x49 fp=0xc0001d26f0 sp=0xc0001d26c8 pc=0x8eefa9
rogchap.com/v8go.NewIsolate()
        /root/go/pkg/mod/rogchap.com/[email protected]/isolate.go:59 +0x3c fp=0xc0001d2728 sp=0xc0001d26f0 pc=0x8f153c
main/agent.New({0x0?, 0x0?}, {0xc000410660, 0x13})
        /root/distribution-game/backend/agent/agent.go:11 +0x2d fp=0xc0001d27b0 sp=0xc0001d2728 pc=0x8f44ad
main.runSimulator.func3()
        /root/distribution-game/backend/main.go:67 +0x32 fp=0xc0001d27e0 sp=0xc0001d27b0 pc=0xa581b2
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0001d27e8 sp=0xc0001d27e0 pc=0x863c61
created by main.runSimulator
        /root/distribution-game/backend/main.go:67 +0x2f4

goroutine 647 [runnable]:
runtime.cgocall(0xa598a0, 0xc0001d3690)
        /usr/local/go/src/runtime/cgocall.go:158 +0x5c fp=0xc0001d3668 sp=0xc0001d3630 pc=0x80295c
rogchap.com/v8go._Cfunc_NewValueUndefined(0x7fae455a76b0)
        _cgo_gotypes.go:897 +0x4d fp=0xc0001d3690 sp=0xc0001d3668 pc=0x8ef8ad
rogchap.com/v8go.newValueUndefined.func1(0x40?)
        /root/go/pkg/mod/rogchap.com/[email protected]/value.go:42 +0x46 fp=0xc0001d36c8 sp=0xc0001d3690 pc=0x8f29e6
rogchap.com/v8go.newValueUndefined(0x7fae455a76b0?)
        /root/go/pkg/mod/rogchap.com/[email protected]/value.go:42 +0x19 fp=0xc0001d36f0 sp=0xc0001d36c8 pc=0x8f2959
rogchap.com/v8go.NewIsolate()
        /root/go/pkg/mod/rogchap.com/[email protected]/isolate.go:63 +0xd0 fp=0xc0001d3728 sp=0xc0001d36f0 pc=0x8f15d0
main/agent.New({0x0?, 0x0?}, {0xc000410660, 0x13})
        /root/distribution-game/backend/agent/agent.go:11 +0x2d fp=0xc0001d37b0 sp=0xc0001d3728 pc=0x8f44ad
main.runSimulator.func3()
        /root/distribution-game/backend/main.go:67 +0x32 fp=0xc0001d37e0 sp=0xc0001d37b0 pc=0xa581b2
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0001d37e8 sp=0xc0001d37e0 pc=0x863c61
created by main.runSimulator
        /root/distribution-game/backend/main.go:67 +0x2f4

goroutine 645 [syscall]:
runtime.cgocall(0xa58d50, 0xc0001c9ef0)
        /usr/local/go/src/runtime/cgocall.go:158 +0x5c fp=0xc0001c9ec8 sp=0xc0001c9e90 pc=0x80295c
rogchap.com/v8go._Cfunc_NewIsolate()
        _cgo_gotypes.go:732 +0x49 fp=0xc0001c9ef0 sp=0xc0001c9ec8 pc=0x8eefa9
rogchap.com/v8go.NewIsolate()
        /root/go/pkg/mod/rogchap.com/[email protected]/isolate.go:59 +0x3c fp=0xc0001c9f28 sp=0xc0001c9ef0 pc=0x8f153c
main/agent.New({0x19690a0?, 0xc0001c9fd0?}, {0xc000410660, 0x13})
        /root/distribution-game/backend/agent/agent.go:11 +0x2d fp=0xc0001c9fb0 sp=0xc0001c9f28 pc=0x8f44ad
main.runSimulator.func3()
        /root/distribution-game/backend/main.go:67 +0x32 fp=0xc0001c9fe0 sp=0xc0001c9fb0 pc=0xa581b2
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0001c9fe8 sp=0xc0001c9fe0 pc=0x863c61
created by main.runSimulator
        /root/distribution-game/backend/main.go:67 +0x2f4

goroutine 646 [syscall]:
runtime.cgocall(0xa58d50, 0xc0001d2ef0)
        /usr/local/go/src/runtime/cgocall.go:158 +0x5c fp=0xc0001d2ec8 sp=0xc0001d2e90 pc=0x80295c
rogchap.com/v8go._Cfunc_NewIsolate()
        _cgo_gotypes.go:732 +0x49 fp=0xc0001d2ef0 sp=0xc0001d2ec8 pc=0x8eefa9
rogchap.com/v8go.NewIsolate()
        /root/go/pkg/mod/rogchap.com/[email protected]/isolate.go:59 +0x3c fp=0xc0001d2f28 sp=0xc0001d2ef0 pc=0x8f153c
main/agent.New({0x0?, 0x0?}, {0xc000410660, 0x13})
        /root/distribution-game/backend/agent/agent.go:11 +0x2d fp=0xc0001d2fb0 sp=0xc0001d2f28 pc=0x8f44ad
main.runSimulator.func3()
        /root/distribution-game/backend/main.go:67 +0x32 fp=0xc0001d2fe0 sp=0xc0001d2fb0 pc=0xa581b2
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0001d2fe8 sp=0xc0001d2fe0 pc=0x863c61
created by main.runSimulator
        /root/distribution-game/backend/main.go:67 +0x2f4

goroutine 352 [syscall]:
runtime.cgocall(0xa58d50, 0xc00043a6f0)
        /usr/local/go/src/runtime/cgocall.go:158 +0x5c fp=0xc00043a6c8 sp=0xc00043a690 pc=0x80295c
rogchap.com/v8go._Cfunc_NewIsolate()
        _cgo_gotypes.go:732 +0x49 fp=0xc00043a6f0 sp=0xc00043a6c8 pc=0x8eefa9
rogchap.com/v8go.NewIsolate()
        /root/go/pkg/mod/rogchap.com/[email protected]/isolate.go:59 +0x3c fp=0xc00043a728 sp=0xc00043a6f0 pc=0x8f153c
main/agent.New({0x0?, 0x0?}, {0xc000410660, 0x13})
        /root/distribution-game/backend/agent/agent.go:11 +0x2d fp=0xc00043a7b0 sp=0xc00043a728 pc=0x8f44ad
main.runSimulator.func3()
        /root/distribution-game/backend/main.go:67 +0x32 fp=0xc00043a7e0 sp=0xc00043a7b0 pc=0xa581b2
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00043a7e8 sp=0xc00043a7e0 pc=0x863c61
created by main.runSimulator
        /root/distribution-game/backend/main.go:67 +0x2f4

goroutine 351 [runnable]:
runtime.cgocall(0xa597c0, 0xc00004f690)
        /usr/local/go/src/runtime/cgocall.go:158 +0x5c fp=0xc00004f668 sp=0xc00004f630 pc=0x80295c
rogchap.com/v8go._Cfunc_NewValueNull(0x7fae2d0e7e90)
        _cgo_gotypes.go:856 +0x4d fp=0xc00004f690 sp=0xc00004f668 pc=0x8ef64d
rogchap.com/v8go.newValueNull.func1(0x40?)
        /root/go/pkg/mod/rogchap.com/[email protected]/value.go:36 +0x46 fp=0xc00004f6c8 sp=0xc00004f690 pc=0x8f2906
rogchap.com/v8go.newValueNull(0x7fae2d0e7e90?)
        /root/go/pkg/mod/rogchap.com/[email protected]/value.go:36 +0x19 fp=0xc00004f6f0 sp=0xc00004f6c8 pc=0x8f2879
rogchap.com/v8go.NewIsolate()
        /root/go/pkg/mod/rogchap.com/[email protected]/isolate.go:62 +0x9c fp=0xc00004f728 sp=0xc00004f6f0 pc=0x8f159c
main/agent.New({0x0?, 0x0?}, {0xc000410660, 0x13})
        /root/distribution-game/backend/agent/agent.go:11 +0x2d fp=0xc00004f7b0 sp=0xc00004f728 pc=0x8f44ad
main.runSimulator.func3()
        /root/distribution-game/backend/main.go:67 +0x32 fp=0xc00004f7e0 sp=0xc00004f7b0 pc=0xa581b2
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00004f7e8 sp=0xc00004f7e0 pc=0x863c61
created by main.runSimulator
        /root/distribution-game/backend/main.go:67 +0x2f4

rax    0x3a
rbx    0x7fae352cef60
rcx    0x7fae95daa398
rdx    0x1
rdi    0x7fae3eff13c0
rsi    0x81
rbp    0x7fae3eff35f0
rsp    0x7fae3eff35f0
r8     0x3a
r9     0x7fffffff
r10    0x0
r11    0x246
r12    0x7fae352d9330
r13    0x1
r14    0x7fae3effbd30
r15    0x19a1a91
rip    0x12bfa8e
rflags 0x202
cs     0x33
fs     0x0
gs     0x0
exit status 2
@jimafisk
Copy link

I'm having the same issue if I try to create around 500+ contexts in goroutines (less than that seems to work fine).

Sample code creating ctx in loop
wg := sync.WaitGroup{}
for _, currentContent := range allContent {
	wg.Add(1)
	go func(currentContent content, wg *sync.WaitGroup) error {
		defer wg.Done()
		ssrCtx, err := createSSRCtx()
		if err != nil {
			return fmt.Errorf("\nCan't create SSR Context for %s %w", currentContent.contentFilepath, err)
		}

                doSomething(ssrCtx)
			
		ssrCtx.Close()
		return nil
	}(currentContent, &wg)
}
wg.Wait()

The createSSRCtx() just creates new ctx and loads some scripts like:

func createSSRCtx() (*v8go.Context, error) {
	ssrCtx := v8go.NewContext(nil)
        // Load some scripts (abbreviated)
        ssrBytes, _ := afero.ReadFile(ssrFS, somepath)
        ssrCtx.RunScript(string(ssrBytes), "create_ssr")
        return ssrCtx, nil
}
Errors
#
# Fatal javascript OOM in GC during deserialization
#


<--- Last few GCs --->


<--- JS stacktrace --->


#
# Fatal javascript OOM in GC during deserialization
#

SIGTRAP: trace trap
PC=0x162f4de m=5 sigcode=128
signal arrived during cgo execution

goroutine 169 [syscall]:
runtime.cgocall(0xdad390, 0xc00092aa58)
	/usr/local/go/src/runtime/cgocall.go:157 +0x5c fp=0xc00092aa30 sp=0xc00092a9f8 pc=0x818d7c
rogchap.com/v8go._Cfunc_NewIsolate()
	_cgo_gotypes.go:741 +0x49 fp=0xc00092aa58 sp=0xc00092aa30 pc=0xb42ca9
rogchap.com/v8go.NewIsolate()
	/home/jimafisk/go/pkg/mod/rogchap.com/[email protected]/isolate.go:59 +0x3c fp=0xc00092aa90 sp=0xc00092aa58 pc=0xb498fc
rogchap.com/v8go.NewContext({0xc00092ab70, 0x1, 0xc0000b6060?})
	/home/jimafisk/go/pkg/mod/rogchap.com/[email protected]/context.go:57 +0x54 fp=0xc00092aae0 sp=0xc00092aa90 pc=0xb47674
github.com/plentico/plenti/cmd/build.createSSRCtx()
	/home/jimafisk/Projects/jantcu/plentico/plenti/cmd/build/data_source.go:250 +0x50 fp=0xc00092ac50 sp=0xc00092aae0 pc=0xbf1bd0
github.com/plentico/plenti/cmd/build.DataSource.func3({{0xc000500988, 0x5}, {0xc0004cc480, 0x9}, {0xc000500a20, 0x1b}, {0xc000263500, 0x355}, {0xc000500980, 0x1c}, ...}, ...)
	/home/jimafisk/Projects/jantcu/plentico/plenti/cmd/build/data_source.go:199 +0x105 fp=0xc00092af20 sp=0xc00092ac50 pc=0xbf08a5
github.com/plentico/plenti/cmd/build.DataSource.func5()
	/home/jimafisk/Projects/jantcu/plentico/plenti/cmd/build/data_source.go:235 +0x5f fp=0xc00092afe0 sp=0xc00092af20 pc=0xbf075f
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc00092afe8 sp=0xc00092afe0 pc=0x879161
created by github.com/plentico/plenti/cmd/build.DataSource
	/home/jimafisk/Projects/jantcu/plentico/plenti/cmd/build/data_source.go:196 +0x134c

goroutine 1 [semacquire]:
sync.runtime_Semacquire(0xc0003e0940?)
	/usr/local/go/src/runtime/sema.go:56 +0x25
sync.(*WaitGroup).Wait(0x1cd8360?)
	/usr/local/go/src/sync/waitgroup.go:136 +0x52
github.com/plentico/plenti/cmd/build.DataSource({0xc000137ba8, 0x6}, {{0xc000137b66, 0x6}, {0x352c758, 0x1}, {0x0, 0x0}, {0xc0000e0720, 0x12}, ...})
	/home/jimafisk/Projects/jantcu/plentico/plenti/cmd/build/data_source.go:238 +0x100d
github.com/plentico/plenti/cmd.Build()
	/home/jimafisk/Projects/jantcu/plentico/plenti/cmd/build.go:156 +0xa49
github.com/plentico/plenti/cmd.glob..func1(0x34f9780?, {0x1d216b8?, 0x1?, 0x1?})
	/home/jimafisk/Projects/jantcu/plentico/plenti/cmd/build.go:54 +0x17
github.com/spf13/cobra.(*Command).execute(0x34f9780, {0xc000191150, 0x1, 0x1})
	/home/jimafisk/go/pkg/mod/github.com/spf13/[email protected]/command.go:856 +0x663
github.com/spf13/cobra.(*Command).ExecuteC(0x34fab80)
	/home/jimafisk/go/pkg/mod/github.com/spf13/[email protected]/command.go:960 +0x39c
github.com/spf13/cobra.(*Command).Execute(...)
	/home/jimafisk/go/pkg/mod/github.com/spf13/[email protected]/command.go:897
github.com/plentico/plenti/cmd.Execute()
	/home/jimafisk/Projects/jantcu/plentico/plenti/cmd/root.go:48 +0x25
main.main()
	/home/jimafisk/Projects/jantcu/plentico/plenti/main.go:7 +0x17

@krvajal
Copy link

krvajal commented Aug 14, 2023

Same here

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