Skip to content

panic: runtime error: index out of range #161

Open
@j1elo

Description

I'm afraid I found a runtime panic while trying to run with https://github.com/livekit/livekit. Hopefully this helps with improving goplantuml's parser.

Curiously, the web version worked fine for me: https://www.dumels.com/diagram/9409c9a6-9f34-4cdb-a15f-fd6256fb4019

But I'd like to also be able to run it locally.

Commands:

go get github.com/jfeliu007/goplantuml/parser
go install github.com/jfeliu007/goplantuml/cmd/goplantuml@latest
git clone https://github.com/livekit/livekit.git
cd livekit/
goplantuml -recursive .

Output:

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/jfeliu007/goplantuml/parser.(*Struct).AddField(0xc0002ef1f0, 0xc0002b6180, 0xc00020d278?)
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/parser/struct.go:99 +0x270
github.com/jfeliu007/goplantuml/parser.handleGenDecStructType(0xc0000b80f0, {0xc00020d278, 0x11}, 0x18?)
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/parser/class_parser.go:300 +0x65
github.com/jfeliu007/goplantuml/parser.(*ClassParser).processSpec(0xc0000b80f0, {0x60cee8?, 0xc0002b60c0?})
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/parser/class_parser.go:340 +0x9b
github.com/jfeliu007/goplantuml/parser.(*ClassParser).handleGenDecl(...)
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/parser/class_parser.go:326
github.com/jfeliu007/goplantuml/parser.(*ClassParser).parseFileDeclarations(0x589f20?, {0x60ca98?, 0xc0002b6340?})
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/parser/class_parser.go:262 +0x8d
github.com/jfeliu007/goplantuml/parser.(*ClassParser).parsePackage(0xc0000b80f0, {0x60c038?, 0xc0001fad20})
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/parser/class_parser.go:232 +0x398
github.com/jfeliu007/goplantuml/parser.(*ClassParser).parseDirectory(0x0?, {0xc0001ea180, 0x38})
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/parser/class_parser.go:253 +0xd8
github.com/jfeliu007/goplantuml/parser.NewClassDiagramWithOptions.func1({0xc0001ea180, 0x38}, {0x60d5f0, 0xc0001f04e0}, {0x0?, 0x0?})
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/parser/class_parser.go:168 +0x10d
github.com/spf13/afero.walk({0x60e200, 0x751f90}, {0xc0001ea180, 0x38}, {0x60d5f0, 0xc0001f04e0}, 0xc000173ab0)
        /home/work/golang/pkg/mod/github.com/spf13/[email protected]/path.go:44 +0x78
github.com/spf13/afero.walk({0x60e200, 0x751f90}, {0xc0000cac90, 0x30}, {0x60d5f0, 0xc00017a410}, 0xc000173ab0)
        /home/work/golang/pkg/mod/github.com/spf13/[email protected]/path.go:69 +0x32d
github.com/spf13/afero.walk({0x60e200, 0x751f90}, {0xc0000ca120, 0x2c}, {0x60d5f0, 0xc0000ad1e0}, 0xc000173ab0)
        /home/work/golang/pkg/mod/github.com/spf13/[email protected]/path.go:69 +0x32d
github.com/spf13/afero.Walk({0x60e200, 0x751f90}, {0xc0000ca120, 0x2c}, 0xc0000c5ab0)
        /home/work/golang/pkg/mod/github.com/spf13/[email protected]/path.go:105 +0x88
github.com/jfeliu007/goplantuml/parser.NewClassDiagramWithOptions(0xc000173c60)
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/parser/class_parser.go:157 +0x2d2
github.com/jfeliu007/goplantuml/parser.NewClassDiagram({0xc0000a0dc0?, 0xc0000c5e70?, 0x8?}, {0x751f90?, 0x0?, 0x1f?}, 0x47?)
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/parser/class_parser.go:208 +0xa5
main.main()
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/cmd/goplantuml/main.go:102 +0xdb0

Other info:

$ go version
go version go1.20.6 linux/amd64

Running on Ubuntu 20.04

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions