Code Monkey home page Code Monkey logo

Comments (3)

tomwilkie avatar tomwilkie commented on August 17, 2024

Rather hard to debug, but if I kill it with SIGQUIT it never seems to be anyone other that the parser, event after a minute:

$ GOMAXPROCS=1 time shfmt -i 4 integration/assert.sh 
SIGQUIT: quit
PC=0x1ce7e m=0

goroutine 5 [running]:
runtime.scanobject(0xc58f140000, 0xc420017228)
    /usr/local/go/src/runtime/mgcmark.go:1163 +0xfe fp=0xc42001ff10 sp=0xc42001fe90
runtime.gcDrain(0xc420017228, 0x5)
    /usr/local/go/src/runtime/mgcmark.go:993 +0x15c fp=0xc42001ff48 sp=0xc42001ff10
runtime.gcBgMarkWorker(0xc420016000)
    /usr/local/go/src/runtime/mgc.go:1452 +0x1d1 fp=0xc42001ffb8 sp=0xc42001ff48
runtime.goexit()
    /usr/local/go/src/runtime/asm_amd64.s:2086 +0x1 fp=0xc42001ffc0 sp=0xc42001ffb8
created by runtime.gcBgMarkStartWorkers
    /usr/local/go/src/runtime/mgc.go:1341 +0x98

goroutine 1 [runnable]:
github.com/mvdan/sh/syntax.(*parser).wordPart(0xc4200683c0, 0xc495b26198, 0x498be00)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:479
github.com/mvdan/sh/syntax.(*parser).wordParts(0xc4200683c0, 0x102100, 0x7865b, 0xc4200683c0)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:465 +0x4b
github.com/mvdan/sh/syntax.(*parser).word(0xc4200683c0, 0xc42008e3d0, 0x1, 0xc42008cc00)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:450 +0x374
github.com/mvdan/sh/syntax.(*parser).followWordTok(0xc4200683c0, 0x51, 0xc2b, 0xc42008e3d0, 0x1, 0x1)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:317 +0x2f
github.com/mvdan/sh/syntax.(*parser).paramExp(0xc4200683c0, 0x1f8000)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:905 +0x701
github.com/mvdan/sh/syntax.(*parser).wordPart(0xc4200683c0, 0x19c2a0, 0xc420084768)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:486 +0x12ad
github.com/mvdan/sh/syntax.(*parser).wordParts(0xc4200683c0, 0xc420011110, 0xbec, 0x1)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:465 +0x4b
github.com/mvdan/sh/syntax.(*parser).wordPart(0xc4200683c0, 0xc41ffff778, 0xc42008d218)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:611 +0x91e
github.com/mvdan/sh/syntax.(*parser).wordParts(0xc4200683c0, 0xc42008e350, 0x1, 0x4)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:465 +0x4b
github.com/mvdan/sh/syntax.(*parser).word(0xc4200683c0, 0xc4200110e0, 0x1, 0x8)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:450 +0x374
github.com/mvdan/sh/syntax.(*parser).getAssign(0xc4200683c0, 0x11df01)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:1001 +0x8c7
github.com/mvdan/sh/syntax.(*parser).getStmt(0xc4200683c0, 0x1, 0xc4200810d8, 0x0)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:1063 +0x7bc
github.com/mvdan/sh/syntax.(*parser).stmts(0xc4200683c0, 0xc42008d5d0, 0x3, 0x3, 0xc420025200, 0xbdb, 0x4)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:420 +0x194
github.com/mvdan/sh/syntax.(*parser).followStmts(0xc4200683c0, 0x11e2db, 0x4, 0xbdb, 0xc42008d5d0, 0x3, 0x3, 0xc420025200, 0x1, 0x4)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:309 +0x7a
github.com/mvdan/sh/syntax.(*parser).ifClause(0xc4200683c0, 0x2)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:1245 +0x1dd
github.com/mvdan/sh/syntax.(*parser).gotStmtPipe(0xc4200683c0, 0xc420081028, 0x1)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:1137 +0x1664
github.com/mvdan/sh/syntax.(*parser).getStmt(0xc4200683c0, 0xc420025101, 0x4, 0x4)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:1087 +0x292
github.com/mvdan/sh/syntax.(*parser).stmts(0xc4200683c0, 0xc42008d8b8, 0x1, 0x1, 0x3fca5, 0x1, 0x0)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:420 +0x194
github.com/mvdan/sh/syntax.(*parser).block(0xc4200683c0, 0x1)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:1232 +0xc1
github.com/mvdan/sh/syntax.(*parser).gotStmtPipe(0xc4200683c0, 0xc420080aa8, 0x1)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:1135 +0x16f7
github.com/mvdan/sh/syntax.(*parser).getStmt(0xc4200683c0, 0xc420010c00, 0x11001, 0x20)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:1087 +0x292
github.com/mvdan/sh/syntax.(*parser).funcDecl(0xc4200683c0, 0x967, 0xc42000c950, 0xa, 0x967, 0x972)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:1664 +0xa9
github.com/mvdan/sh/syntax.(*parser).gotStmtPipe(0xc4200683c0, 0xc420080a50, 0x1)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:1163 +0xe0d
github.com/mvdan/sh/syntax.(*parser).getStmt(0xc4200683c0, 0xc42000a601, 0x8, 0x8)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:1087 +0x292
github.com/mvdan/sh/syntax.(*parser).stmts(0xc4200683c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1805)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:420 +0x194
github.com/mvdan/sh/syntax.Parse(0xc42007e000, 0x1805, 0x1e00, 0x7fff5fbffb83, 0x15, 0x1, 0x0, 0x7fff5fbffb8f, 0x9)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/syntax/parser.go:42 +0x1a8
main.formatPath(0x7fff5fbffb83, 0x15, 0x19cf00, 0x0, 0x0)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/cmd/shfmt/main.go:176 +0x229
main.walk(0x7fff5fbffb83, 0x15, 0xc42000c670)
    /Users/twilkie/Documents/src/github.com/mvdan/sh/cmd/shfmt/main.go:125 +0x124
main.main()
    /Users/twilkie/Documents/src/github.com/mvdan/sh/cmd/shfmt/main.go:65 +0x170

rax    0xc420000000
rbx    0xc414236f7f
rcx    0x0
rdx    0xc5eb030000
rdi    0x5beee000
rsi    0xc58f140000
rbp    0xc42001ff00
rsp    0xc42001fe90
r8     0x0
r9     0xc7e1000
r10    0xc59b921000
r11    0xc434020d80
r12    0x0
r13    0xc420001860
r14    0x3ae20
r15    0x15eb08
rip    0x1ce7e
rflags 0x10202
cs     0x2b
fs     0x0
gs     0x0
       49.74 real        38.15 user         8.98 sys

from sh.

tomwilkie avatar tomwilkie commented on August 17, 2024

Quick bisect points to this change 0194505

Toms-MacBook-Pro:sh twilkie$ git bisect start 
Toms-MacBook-Pro:sh twilkie$ git bisect bad 
Toms-MacBook-Pro:sh twilkie$ git bisect good c9059b77875cd76651bb7e6fe6fef7d216372f07
Bisecting: 42 revisions left to test after this (roughly 5 steps)
[49f625302fcebaada4dfbc5ec056b4e7cdd299c3] syntax: add package doc
Toms-MacBook-Pro:sh twilkie$ go build ./cmd/shfmt && ./shfmt -i 4 ../../weaveworks/build-tools/integration/assert.sh >/dev/null
Toms-MacBook-Pro:sh twilkie$ git bisect good
Bisecting: 21 revisions left to test after this (roughly 5 steps)
[48ad4a448495d70805457c02aa0344d45f4ee162] syntax: split arithm and test expression nodes
Toms-MacBook-Pro:sh twilkie$ go build ./cmd/shfmt && ./shfmt -i 4 ../../weaveworks/build-tools/integration/assert.sh >/dev/null
Toms-MacBook-Pro:sh twilkie$ git bisect good
Bisecting: 10 revisions left to test after this (roughly 4 steps)
[5316ff63cea968af78dd3ad6750cf54bddebbf0b] syntax: don't write ; twice in a row
Toms-MacBook-Pro:sh twilkie$ go build ./cmd/shfmt && ./shfmt -i 4 ../../weaveworks/build-tools/integration/assert.sh >/dev/null
Toms-MacBook-Pro:sh twilkie$ git bisect good
Bisecting: 5 revisions left to test after this (roughly 3 steps)
[1e3082cfd410e31745eca89e53d59f5aef761a38] syntax: run some parent tests in parallel
Toms-MacBook-Pro:sh twilkie$ go build ./cmd/shfmt && ./shfmt -i 4 ../../weaveworks/build-tools/integration/assert.sh >/dev/null
^C
Toms-MacBook-Pro:sh twilkie$ git bisect bad
Bisecting: 2 revisions left to test after this (roughly 1 step)
[01945053961cf3d575733f42345dca2ca1258ee6] syntax: support plus and minus signs in slices
Toms-MacBook-Pro:sh twilkie$ go build ./cmd/shfmt && ./shfmt -i 4 ../../weaveworks/build-tools/integration/assert.sh >/dev/null
^C
Toms-MacBook-Pro:sh twilkie$ git bisect bad
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[0a4761ee498179b93fe0efcd37758320c6ec73cd] syntax: remove duplicate check
Toms-MacBook-Pro:sh twilkie$ go build ./cmd/shfmt && ./shfmt -i 4 ../../weaveworks/build-tools/integration/assert.sh >/dev/null
Toms-MacBook-Pro:sh twilkie$ git bisect good
01945053961cf3d575733f42345dca2ca1258ee6 is the first bad commit
commit 01945053961cf3d575733f42345dca2ca1258ee6
Author: Daniel Martí <[email protected]>
Date:   Fri Nov 4 22:11:40 2016 +0000

    syntax: support plus and minus signs in slices

    Bash seems to support arithmetic expressions there, but for now this is
    better than nothing.

:040000 040000 691b4f449bae2b86856db035a54e02fb998f5305 0a70cd33bd8ef0b921b487f52851b005afb65c54 M  syntax

from sh.

mvdan avatar mvdan commented on August 17, 2024

Thanks for reporting!

I usually fuzz the whole thing to avoid hangs and panics (see the README). Ideally I would do it after every change, but it really slows down my development. As such, I do it before tagging a release and every once in a while otherwise. I've been rewriting stuff in the last few days and have been too lazy to fuzz still, but I will now :)

from sh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.