Gopherjs: Circular imports lead to stack overflow crash

Created on 29 Feb 2016  路  4Comments  路  Source: gopherjs/gopherjs

main.go:

package main

import "github.com/flimzy/jstest/foo"

foo/foo.go:

package foo

import "github.com/flimzy/jstest/bar"

bar/bar.go:

package bar

import "github.com/flimzy/jstest/foo"

gopherjs build crashes (after about 25 seconds):

$ gopherjs build
runtime: goroutine stack exceeds 1000000000-byte limit
fatal error: stack overflow

runtime stack:
runtime.throw(0xaf0010, 0xe)
        /usr/local/go/src/runtime/panic.go:530 +0x90
runtime.newstack()
        /usr/local/go/src/runtime/stack.go:940 +0xb11
runtime.morestack()
        /usr/local/go/src/runtime/asm_amd64.s:359 +0x7f
<snip>
NeedsFix bug gopherjs-tool

Most helpful comment

Thanks @shurcooL your edit clarified things.

So I guess my drive by comment, and it's an obvious one, is that we need to ensure that gopherjs serve also reports such circular imports as errors.

All 4 comments

I can confirm this appears to be resolved on my WIP implementation of #388.

$ go build
import cycle not allowed
package github.com/shurcooL/play/31
    imports github.com/shurcooL/play/31/a
    imports github.com/shurcooL/play/31/b
    imports github.com/shurcooL/play/31/a
$ gopherjs build
import cycle not allowed
package github.com/shurcooL/play/31
    imports github.com/shurcooL/play/31/a
    imports github.com/shurcooL/play/31/b
    imports github.com/shurcooL/play/31/a

@shurcooL your fix presumably reports the import cycle via gopherjs serve too? Came up via https://github.com/myitcv/react/issues/68

Which fix are you referring to? The one I mentioned in the comment above was https://github.com/gopherjs/gopherjs/pull/485#issuecomment-281441761, which is an abandoned PR.

Edit: To be clear, this is an open and unresolved issue. It needs a fix. The previous attempt is unlikely to be helpful, because it fixed the issue by entirely replacing the build system with that of cmd/go.

Thanks @shurcooL your edit clarified things.

So I guess my drive by comment, and it's an obvious one, is that we need to ensure that gopherjs serve also reports such circular imports as errors.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

canning-duck picture canning-duck  路  3Comments

Jimmy99 picture Jimmy99  路  5Comments

damz picture damz  路  3Comments

nytehauq picture nytehauq  路  7Comments

dmitshur picture dmitshur  路  4Comments