Skip to content

std.objectRemoveKey panics when given extended objects #808

@ushitora-anqou

Description

@ushitora-anqou

The following code panics

std.objectRemoveKey({}+{}, "")

with the following error

❯ jsonnet --version        
Jsonnet commandline interpreter (Go implementation) v0.21.0

❯ cat misc/bug1.jsonnet 
std.objectRemoveKey({}+{}, "")

❯ jsonnet misc/bug1.jsonnet
INTERNAL ERROR: (CRASH) interface conversion: jsonnet.uncachedObject is *jsonnet.extendedObject, not *jsonnet.simpleObject
goroutine 1 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x5e
github.com/google/go-jsonnet.(*VM).Evaluate.func1()
	github.com/google/go-jsonnet/vm.go:187 +0x3d
panic({0x5e95a0?, 0xc0001b8900?})
	runtime/panic.go:792 +0x132
github.com/google/go-jsonnet.builtInObjectRemoveKey(0xc000190500, {0x683f60, 0xc0001b8870}, {0x683ee8, 0xc00000ef30})
	github.com/google/go-jsonnet/builtins.go:2512 +0x3e6
github.com/google/go-jsonnet.(*binaryBuiltin).evalCall(0xc0000e50e0, {{0xc000049a40, 0x2, 0x2}, {0x9ea4e0, 0x0, 0x0}, 0x0}, 0xc000190500)
	github.com/google/go-jsonnet/builtins.go:2625 +0x20e
github.com/google/go-jsonnet.(*valueFunction).call(0xc000049590, 0xc000190500, {{0xc000049a40, 0x2, 0x2}, {0x9ea4e0, 0x0, 0x0}, 0x0})
	github.com/google/go-jsonnet/value.go:349 +0x122
github.com/google/go-jsonnet.(*interpreter).evaluateTailCall(0x685628?, 0xc000054100?, {{0xc000049a40, 0x2, 0x2}, {0x9ea4e0, 0x0, 0x0}, 0x0}, 0x1)
	github.com/google/go-jsonnet/interpreter.go:1037 +0x9d
github.com/google/go-jsonnet.(*interpreter).rawevaluate(0xc000190500, {0x685628, 0xc000054100}, 0x1)
	github.com/google/go-jsonnet/interpreter.go:621 +0x3be5
github.com/google/go-jsonnet.(*interpreter).evaluate(0xc000190500, {0x685628, 0xc000054100}, 0x1)
	github.com/google/go-jsonnet/interpreter.go:312 +0x4e
github.com/google/go-jsonnet.(*interpreter).EvalInCleanEnv(0xc000190500, 0x11?, {0x685628, 0xc000054100}, 0x10?)
	github.com/google/go-jsonnet/interpreter.go:1019 +0x5f
github.com/google/go-jsonnet.evaluateAux(0xc000190500, {0x685628, 0xc000054100}, 0xc0000e5dd0)
	github.com/google/go-jsonnet/interpreter.go:1327 +0x147
github.com/google/go-jsonnet.evaluate({0x685628, 0xc000054100}, 0xc0001ddd68?, 0xc0000e5dd0, 0x5ea920?, 0xc0000e5f20?, 0x7ffe65d92fdf?, {0x6838c0?, 0xc0000b2040?}, 0x0, ...)
	github.com/google/go-jsonnet/interpreter.go:1362 +0x91
github.com/google/go-jsonnet.(*VM).Evaluate(0xc0001b8000?, {0x685628?, 0xc000054100?})
	github.com/google/go-jsonnet/vm.go:190 +0xba
github.com/google/go-jsonnet.(*VM).EvaluateFile(0xc0001b0230, {0x7ffe65d92fdf?, 0xc0000e5cb0?})
	github.com/google/go-jsonnet/vm.go:419 +0xb4
main.main()
	github.com/google/go-jsonnet/cmd/jsonnet/cmd.go:457 +0x6c5

Please report a bug here: https://github.com/google/go-jsonnet/issues

Seemingly this line crashed:
https://github.com/google/go-jsonnet/blob/v0.21.0/builtins.go#L2512

We need to take care of the situation where obj.uncached isn't a simpleObject.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions