From a0984dcdd3066d057012c99f2cb7f01a3961d9ee Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sun, 2 May 2021 16:50:29 +1000 Subject: [PATCH] Limit the number of coroutines per type to 0x7FFF --- internal/cgen/func.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/cgen/func.go b/internal/cgen/func.go index f85b1ccf..eca0bedd 100644 --- a/internal/cgen/func.go +++ b/internal/cgen/func.go @@ -292,6 +292,9 @@ func (g *gen) gatherFuncImpl(_ *buffer, n *a.Func) error { if n.Public() && n.Effect().Coroutine() { g.numPublicCoroutines[n.Receiver()]++ coroID = g.numPublicCoroutines[n.Receiver()] + if coroID >= 0x8000 { + return fmt.Errorf("too many coroutines for %q", n.Receiver().Str(g.tm)) + } } g.currFunk = funk{