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 in Compile #352

Closed
mrduncan opened this issue Dec 10, 2021 · 0 comments
Closed

Panic in Compile #352

mrduncan opened this issue Dec 10, 2021 · 0 comments
Labels

Comments

@mrduncan
Copy link

I found this interesting case during some fuzzing:

package main

import (
	"github.com/dop251/goja"
)

func main() {
	goja.Compile("", "({!:0})", false)
}
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x1227f5b]

goroutine 1 [running]:
github.com/dop251/goja.compileAST.func1()
	/Users/matt/go/pkg/mod/github.com/dop251/goja@v0.0.0-20211207134806-acd374ca9c94/runtime.go:1305 +0xb4
panic({0x133e160, 0x1797320})
	/usr/local/Cellar/go/1.17.3/libexec/src/runtime/panic.go:1038 +0x215
github.com/dop251/goja.(*compiledObjectLiteral).emitGetter(0xc00000c330, 0x1)
	/Users/matt/go/pkg/mod/github.com/dop251/goja@v0.0.0-20211207134806-acd374ca9c94/compiler_expr.go:1790 +0x45b
github.com/dop251/goja.(*compiler).compileExpressionStatement(0xc00006e510, 0x1012fa5, 0x1)
	/Users/matt/go/pkg/mod/github.com/dop251/goja@v0.0.0-20211207134806-acd374ca9c94/compiler_stmt.go:965 +0x83
github.com/dop251/goja.(*compiler).compileStatement(0x203000, {0x13f8f88, 0xc00001e4e0}, 0x10)
	/Users/matt/go/pkg/mod/github.com/dop251/goja@v0.0.0-20211207134806-acd374ca9c94/compiler_stmt.go:18 +0x413
github.com/dop251/goja.(*compiler).compileStatementsNeedResult(0x17a2f80, {0xc00001e4f0, 0x1, 0x1}, 0x0)
	/Users/matt/go/pkg/mod/github.com/dop251/goja@v0.0.0-20211207134806-acd374ca9c94/compiler_stmt.go:883 +0x1bf
github.com/dop251/goja.(*compiler).compileStatements(0xc00006e510, {0xc00001e4f0, 0x1, 0x1}, 0x1)
	/Users/matt/go/pkg/mod/github.com/dop251/goja@v0.0.0-20211207134806-acd374ca9c94/compiler_stmt.go:910 +0x7b
github.com/dop251/goja.(*compiler).compile(0xc00006e510, 0xc00007c1c0, 0x0, 0x0, 0x1)
	/Users/matt/go/pkg/mod/github.com/dop251/goja@v0.0.0-20211207134806-acd374ca9c94/compiler.go:748 +0xbca
github.com/dop251/goja.compileAST(0x0, 0x0, 0x0, 0x0)
	/Users/matt/go/pkg/mod/github.com/dop251/goja@v0.0.0-20211207134806-acd374ca9c94/runtime.go:1310 +0x107
github.com/dop251/goja.compile({0x0, 0x0}, {0x138ad3e, 0x1326200}, 0xa0, 0x1, 0x0, {0x0, 0x0, 0x0})
	/Users/matt/go/pkg/mod/github.com/dop251/goja@v0.0.0-20211207134806-acd374ca9c94/runtime.go:1292 +0x6a
github.com/dop251/goja.Compile(...)
	/Users/matt/go/pkg/mod/github.com/dop251/goja@v0.0.0-20211207134806-acd374ca9c94/runtime.go:1243
main.main()
	/Users/matt/code/scratch/main.go:8 +0x45
exit status 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants