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

Panic on a mode having no patterns #6

Open
nihei9 opened this issue Mar 21, 2022 · 0 comments
Open

Panic on a mode having no patterns #6

nihei9 opened this issue Mar 21, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@nihei9
Copy link
Owner

nihei9 commented Mar 21, 2022

When a mode contains no patterns, not fragments, maleeni v0.6.0 panics.

I made the following file:

{
	"name": "test",
	"entries": [
		{
			"modes": ["other_mode"],
			"kind": "foo",
			"pattern": "foo"
		}
	]
}

Then I got the following error:

$ maleeni compile test.json
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x5b2510]

goroutine 1 [running]:
github.com/nihei9/maleeni/compiler/dfa.GenDFA(0x0, 0x0, 0xc000118dd0, 0xc000118dd0)
        /home/nihei9/src/github.com/nihei9/maleeni/compiler/dfa/dfa.go:51 +0x50
github.com/nihei9/maleeni/compiler.compile(0x832280, 0x0, 0x0, 0xc00011b350, 0xc00011b3b0, 0xc0001a4f78, 0xc00014c400, 0x3, 0x4, 0xc00011b350, ...)
        /home/nihei9/src/github.com/nihei9/maleeni/compiler/compiler.go:323 +0x1b7d
github.com/nihei9/maleeni/compiler.Compile(0xc00011b050, 0xc0001add18, 0x1, 0x1, 0x0, 0xc0001b8100, 0xc0001add10, 0xc0001add38, 0xc0001add38, 0x5cd065)
        /home/nihei9/src/github.com/nihei9/maleeni/compiler/compiler.go:57 +0x9a7
main.runCompile(0xc000154f00, 0xc000118ad0, 0x1, 0x1, 0x0, 0x0)
        /home/nihei9/src/github.com/nihei9/maleeni/cmd/maleeni/compile.go:49 +0xe5
github.com/spf13/cobra.(*Command).execute(0xc000154f00, 0xc000118ab0, 0x1, 0x1, 0xc000154f00, 0xc000118ab0)
        /home/nihei9/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:852 +0x472
github.com/spf13/cobra.(*Command).ExecuteC(0x800100, 0x4407dc, 0xc000000180, 0x300000002)
        /home/nihei9/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        /home/nihei9/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
main.Execute(0x7e9d88, 0xc00010e058)
        /home/nihei9/src/github.com/nihei9/maleeni/cmd/maleeni/root.go:22 +0x31
main.main()
        /home/nihei9/src/github.com/nihei9/maleeni/cmd/maleeni/main.go:8 +0x25

The following spec causes the same error.

{
	"name": "test",
	"entries": [
		{
			"kind": "foo",
			"fragment": true,
			"pattern": "foo"
		}
	]
}
@nihei9 nihei9 added the bug Something isn't working label Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant