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

Stack overflow by $ref in targetSchema #29

Closed
naoina opened this issue Nov 22, 2014 · 6 comments · Fixed by #39
Closed

Stack overflow by $ref in targetSchema #29

naoina opened this issue Nov 22, 2014 · 6 comments · Fixed by #39

Comments

@naoina
Copy link

naoina commented Nov 22, 2014

In this example, save the following JSON Schema as infinite.json.

{
  "definitions": {
    "addon-service": {
      "definitions": {
      },
      "links": [
        {
          "targetSchema": {
            "$ref": "#/definitions/addon-service"
          }
        }
      ]
    }
  },
  "title": "infinite recursive test"
}

When run the schematic infinite.json then it will panic by stack overflow as follows.

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

runtime stack:
runtime.throw(0x72580e)
        /home/naoina/.gvm/gos/go1.3.3/src/pkg/runtime/panic.c:520 +0x69
runtime.newstack()
        /home/naoina/.gvm/gos/go1.3.3/src/pkg/runtime/stack.c:770 +0x486
runtime.morestack()
        /home/naoina/.gvm/gos/go1.3.3/src/pkg/runtime/asm_amd64.s:228 +0x61

goroutine 16 [stack growth]:
strings.genSplit(0xc20800f780, 0x1b, 0x603270, 0x1, 0x0, 0xffffffffffffffff, 0xc20800f780, 0x6027d0, 0x1)
        /home/naoina/.gvm/gos/go1.3.3/src/pkg/strings/strings.go:244 fp=0xc2681000d0 sp=0xc2681000c8
strings.Split(0xc20800f780, 0x1b, 0x603270, 0x1, 0x0, 0x0, 0x0)
        /home/naoina/.gvm/gos/go1.3.3/src/pkg/strings/strings.go:294 +0x7a fp=0xc268100120 sp=0xc2681000d0
github.com/interagent/schematic.Reference.Resolve(0xc20800f780, 0x1b, 0xc20806e200, 0x7f1e8a4421d8)
        /home/naoina/work/src/github.com/interagent/schematic/reference.go:28 +0x232 fp=0xc2681004b0 sp=0xc268100120
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e800, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:92 +0x3d2 fp=0xc268100708 sp=0xc2681004b0
github.com/interagent/schematic.(*Link).Resolve(0xc2681008c8, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268100728 sp=0xc268100708
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268100980 sp=0xc268100728
github.com/interagent/schematic.(*Link).Resolve(0xc268100b40, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc2681009a0 sp=0xc268100980
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268100bf8 sp=0xc2681009a0
github.com/interagent/schematic.(*Link).Resolve(0xc268100db8, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268100c18 sp=0xc268100bf8
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268100e70 sp=0xc268100c18
github.com/interagent/schematic.(*Link).Resolve(0xc268101030, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268100e90 sp=0xc268100e70
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc2681010e8 sp=0xc268100e90
github.com/interagent/schematic.(*Link).Resolve(0xc2681012a8, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268101108 sp=0xc2681010e8
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268101360 sp=0xc268101108
github.com/interagent/schematic.(*Link).Resolve(0xc268101520, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268101380 sp=0xc268101360
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc2681015d8 sp=0xc268101380
github.com/interagent/schematic.(*Link).Resolve(0xc268101798, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc2681015f8 sp=0xc2681015d8
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268101850 sp=0xc2681015f8
github.com/interagent/schematic.(*Link).Resolve(0xc268101a10, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268101870 sp=0xc268101850
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268101ac8 sp=0xc268101870
github.com/interagent/schematic.(*Link).Resolve(0xc268101c88, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268101ae8 sp=0xc268101ac8
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268101d40 sp=0xc268101ae8
github.com/interagent/schematic.(*Link).Resolve(0xc268101f00, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268101d60 sp=0xc268101d40
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268101fb8 sp=0xc268101d60
github.com/interagent/schematic.(*Link).Resolve(0xc268102178, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268101fd8 sp=0xc268101fb8
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268102230 sp=0xc268101fd8
github.com/interagent/schematic.(*Link).Resolve(0xc2681023f0, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268102250 sp=0xc268102230
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc2681024a8 sp=0xc268102250
github.com/interagent/schematic.(*Link).Resolve(0xc268102668, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc2681024c8 sp=0xc2681024a8
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268102720 sp=0xc2681024c8
github.com/interagent/schematic.(*Link).Resolve(0xc2681028e0, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268102740 sp=0xc268102720
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268102998 sp=0xc268102740
github.com/interagent/schematic.(*Link).Resolve(0xc268102b58, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc2681029b8 sp=0xc268102998
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268102c10 sp=0xc2681029b8
github.com/interagent/schematic.(*Link).Resolve(0xc268102dd0, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268102c30 sp=0xc268102c10
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268102e88 sp=0xc268102c30
github.com/interagent/schematic.(*Link).Resolve(0xc268103048, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268102ea8 sp=0xc268102e88
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268103100 sp=0xc268102ea8
github.com/interagent/schematic.(*Link).Resolve(0xc2681032c0, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268103120 sp=0xc268103100
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268103378 sp=0xc268103120
github.com/interagent/schematic.(*Link).Resolve(0xc268103538, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268103398 sp=0xc268103378
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc2681035f0 sp=0xc268103398
github.com/interagent/schematic.(*Link).Resolve(0xc2681037b0, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268103610 sp=0xc2681035f0
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268103868 sp=0xc268103610
github.com/interagent/schematic.(*Link).Resolve(0xc268103a28, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268103888 sp=0xc268103868
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268103ae0 sp=0xc268103888
github.com/interagent/schematic.(*Link).Resolve(0xc268103ca0, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268103b00 sp=0xc268103ae0
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268103d58 sp=0xc268103b00
github.com/interagent/schematic.(*Link).Resolve(0xc268103f18, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268103d78 sp=0xc268103d58
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268103fd0 sp=0xc268103d78
github.com/interagent/schematic.(*Link).Resolve(0xc268104190, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268103ff0 sp=0xc268103fd0
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268104248 sp=0xc268103ff0
github.com/interagent/schematic.(*Link).Resolve(0xc268104408, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268104268 sp=0xc268104248
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc2681044c0 sp=0xc268104268
github.com/interagent/schematic.(*Link).Resolve(0xc268104680, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc2681044e0 sp=0xc2681044c0
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268104738 sp=0xc2681044e0
github.com/interagent/schematic.(*Link).Resolve(0xc2681048f8, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268104758 sp=0xc268104738
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc2681049b0 sp=0xc268104758
github.com/interagent/schematic.(*Link).Resolve(0xc268104b70, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc2681049d0 sp=0xc2681049b0
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268104c28 sp=0xc2681049d0
github.com/interagent/schematic.(*Link).Resolve(0xc268104de8, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268104c48 sp=0xc268104c28
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268104ea0 sp=0xc268104c48
github.com/interagent/schematic.(*Link).Resolve(0xc268105060, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268104ec0 sp=0xc268104ea0
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268105118 sp=0xc268104ec0
github.com/interagent/schematic.(*Link).Resolve(0xc2681052d8, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268105138 sp=0xc268105118
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268105390 sp=0xc268105138
github.com/interagent/schematic.(*Link).Resolve(0xc268105550, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc2681053b0 sp=0xc268105390
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268105608 sp=0xc2681053b0
github.com/interagent/schematic.(*Link).Resolve(0xc2681057c8, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268105628 sp=0xc268105608
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268105880 sp=0xc268105628
github.com/interagent/schematic.(*Link).Resolve(0xc268105a40, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc2681058a0 sp=0xc268105880
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268105af8 sp=0xc2681058a0
github.com/interagent/schematic.(*Link).Resolve(0xc268105cb8, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268105b18 sp=0xc268105af8
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268105d70 sp=0xc268105b18
github.com/interagent/schematic.(*Link).Resolve(0xc268105f30, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268105d90 sp=0xc268105d70
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268105fe8 sp=0xc268105d90
github.com/interagent/schematic.(*Link).Resolve(0xc2681061a8, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268106008 sp=0xc268105fe8
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268106260 sp=0xc268106008
github.com/interagent/schematic.(*Link).Resolve(0xc268106420, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268106280 sp=0xc268106260
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc2681064d8 sp=0xc268106280
github.com/interagent/schematic.(*Link).Resolve(0xc268106698, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc2681064f8 sp=0xc2681064d8
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268106750 sp=0xc2681064f8
github.com/interagent/schematic.(*Link).Resolve(0xc268106910, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268106770 sp=0xc268106750
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc2681069c8 sp=0xc268106770
github.com/interagent/schematic.(*Link).Resolve(0xc268106b88, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc2681069e8 sp=0xc2681069c8
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268106c40 sp=0xc2681069e8
github.com/interagent/schematic.(*Link).Resolve(0xc268106e00, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268106c60 sp=0xc268106c40
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268106eb8 sp=0xc268106c60
github.com/interagent/schematic.(*Link).Resolve(0xc268107078, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268106ed8 sp=0xc268106eb8
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268107130 sp=0xc268106ed8
github.com/interagent/schematic.(*Link).Resolve(0xc2681072f0, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268107150 sp=0xc268107130
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc2681073a8 sp=0xc268107150
github.com/interagent/schematic.(*Link).Resolve(0xc268107568, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc2681073c8 sp=0xc2681073a8
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268107620 sp=0xc2681073c8
github.com/interagent/schematic.(*Link).Resolve(0xc2681077e0, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268107640 sp=0xc268107620
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268107898 sp=0xc268107640
github.com/interagent/schematic.(*Link).Resolve(0xc268107a58, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc2681078b8 sp=0xc268107898
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268107b10 sp=0xc2681078b8
github.com/interagent/schematic.(*Link).Resolve(0xc268107cd0, 0xc20806e200)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:278 +0x72 fp=0xc268107b30 sp=0xc268107b10
github.com/interagent/schematic.(*Schema).Resolve(0xc20806e600, 0xc20806e200, 0x0)
        /home/naoina/work/src/github.com/interagent/schematic/gen.go:101 +0x58d fp=0xc268107d88 sp=0xc268107b30
...additional frames elided...
created by _rt0_go
        /home/naoina/.gvm/gos/go1.3.3/src/pkg/runtime/asm_amd64.s:97 +0x120

goroutine 19 [finalizer wait]:
runtime.park(0x413250, 0x727f38, 0x726a29)
        /home/naoina/.gvm/gos/go1.3.3/src/pkg/runtime/proc.c:1369 +0x89
runtime.parkunlock(0x727f38, 0x726a29)
        /home/naoina/.gvm/gos/go1.3.3/src/pkg/runtime/proc.c:1385 +0x3b
runfinq()
        /home/naoina/.gvm/gos/go1.3.3/src/pkg/runtime/mgc0.c:2644 +0xcf
runtime.goexit()
        /home/naoina/.gvm/gos/go1.3.3/src/pkg/runtime/proc.c:1445
@cyberdelia
Copy link
Member

It's a know bug that waits for a good solution.

@shutej
Copy link

shutej commented Jul 5, 2015

So I think it'd be really useful to fix this. This bug seems to come from a few places...

  • Resolving references is done with a depth-first search that recurses infinitely. I think the package should probably use some kind of marking to find cycles.
  • The package's current design seems to output types directly. However, once you find cycles, those types will need to be output with a name, such that they can be self-referential.

As an example of a self-referential type, consider this example. I think this would be impossible to represent in Go without first naming the type, right?

In general, I would think that it would be useful to use a 3rd party package that has excellent support for JSON Schema and outsource the responsibilities of parsing and representation there. Right now there is such a package, github.com/xeipuuv/gojsonschema, but the package does not expose its internals yet. I've created a bug over there that highlights a potential approach to exposing the parsed schema:

xeipuuv/gojsonschema#15

I think that visitor design has to account for cyclic types in some way such that this package could stop recursing.

The remaining set of responsibilities in this package would be to move to outputting NAMED types, at least where they required (such as the case of cycles, including types that are mutually recursive). This would be a fairly major change, overall. I'd want to know that the general direction would be acceptable to both parties before embarking on such an adventure. @cyberdelia @brandur would you be interested in seeing such a change?

How much support is coming from Heroku on this project?

@cyberdelia
Copy link
Member

Yes.

schematic is desperately in needs of a new reference resolver, the current one was written for a previous generation of the JSON schema specs, where self-reference was not a such a common thing, and this is pretty much why schematic is not very useful today.

Unfortunately, I have little time to try to tackle this, but would welcome something in that direction.

@brandur
Copy link
Member

brandur commented Jul 7, 2015

@shutej Great summary of the situation. Thanks!

The remaining set of responsibilities in this package would be to move to outputting NAMED types, at least where they required (such as the case of cycles, including types that are mutually recursive). This would be a fairly major change, overall. I'd want to know that the general direction would be acceptable to both parties before embarking on such an adventure. @cyberdelia @brandur would you be interested in seeing such a change?

I'd personally love to see this change. As mentioned in the other thread though, the way we're currently organized internally is leading to a poor maintenance story for our client software like Schematic. I think there's a possibility this could change in the next few months, but at the moment we don't have that many resources to throw at this problem.

Also CC @geemus for general interest on this one.

@geemus
Copy link
Member

geemus commented Jul 9, 2015

Yeah, would definitely support fixes, but lack bandwidth internally to be able to move it forward currently.

@alindeman
Copy link
Contributor

@geemus @cyberdelia I've taken a stab at this over in #39. Feedback welcomed.

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

Successfully merging a pull request may close this issue.

6 participants