jk icon indicating copy to clipboard operation
jk copied to clipboard

fatal panic during exection due to import cycle

Open jaxxstorm opened this issue 4 years ago • 1 comments

This might be hard to track down, but here goes.

I have a crappy library: https://github.com/jaxxstorm/pulumi-action-config

And a crappy js workflow file:

import * as g from '@jaxxstorm/pulumi-action-config/workflow';
import * as param from '@jkcfg/std/param';

const provider = param.String('provider')
const prWorkflow = name => new g.GithubWorkflow(`pull-request`,
  { GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}", GO111MODULE: "on", PROVIDER: provider })

const releaseWorkflow = name => new g.GithubReleaseWorkFlow(`release`,
  { GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}", GO111MODULE: "on", PROVIDER: provider })

export default [
  { value: prWorkflow('pull-request'), file: 'pull-request.yml' },
  { value: releaseWorkflow('release'), file: 'release.yml' },

];

you can see this here: https://github.com/jaxxstorm/pulumi-action-config/blob/master/workflow.js

I'm running jk generate workflow.js and getting a nasty panic:

fatal: morestack on g0
SIGTRAP: trace trap
PC=0x405b1c2 m=0 sigcode=1
signal arrived during cgo execution

goroutine 1 [running, locked to thread]:
runtime.abort()
	/Users/travis/go-1.13.8/src/runtime/asm_amd64.s:859 +0x2 fp=0x7ffeefb807d0 sp=0x7ffeefb807c8 pc=0x405b1c2
runtime.morestack()
	/Users/travis/go-1.13.8/src/runtime/asm_amd64.s:416 +0x25 fp=0x7ffeefb807d8 sp=0x7ffeefb807d0 pc=0x4059885

rax    0x17
rbx    0x7ffeefb807a0
rcx    0x5327a40
rdx    0x0
rdi    0x2
rsi    0x7ffeefb80740
rbp    0x7ffeefb80850
rsp    0x7ffeefb807c8
r8     0x5327a40
r9     0x1
r10    0x7ffeefb807a0
r11    0x206
r12    0x40
r13    0x40
r14    0x3f
r15    0x40
rip    0x405b1c2
rflags 0x202
cs     0x2b
fs     0x0
gs     0x0

This only happens when I'm including my library, which is a reference to a git URL in my package.json:

{
  "name": "ci",
  "version": "1.0.0",
  "description": "",
  "main": "workflow.js",
  "dependencies": {
    "@jaxxstorm/pulumi-action-config": "git+https://[email protected]/jaxxstorm/pulumi-action-config.git"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "license": "Apache-2.0"
}

I'm sure there's something wrong with my crappy library, but jk shouldn't panic :)

jaxxstorm avatar May 21 '20 18:05 jaxxstorm

The script @jaxxstorm/pulumi-action-config/workflow imports itself. I absolutely agree it shouldn't segfault though! I can reproduce this with:

// foo.js
import * as f from 'foo';

I thought we guarded against cycles in imports; apparently not, or at least it has broken.

squaremo avatar May 25 '20 21:05 squaremo