brimdata / zed

A novel data lake based on super-structured data
https://zed.brimdata.io/
BSD 3-Clause "New" or "Revised" License
1.34k stars 67 forks source link

Panic due to null math #5158

Open philrz opened 2 days ago

philrz commented 2 days ago

Repro is with Zed commit 19b2eb5.

$ zq -version
Version: v1.14.0-29-g19b2eb5d

$ zq 'yield null +1'
panic: null
goroutine 1 [running]:
runtime/debug.Stack()
    /usr/local/opt/go@1.21/libexec/src/runtime/debug/stack.go:24 +0x5e
github.com/brimdata/zed/runtime/sam/op.(*Catcher).Pull.func1()
    /Users/phil/work/zed/runtime/sam/op/catcher.go:25 +0x3d
panic({0x2360980?, 0xc000557430?})
    /usr/local/opt/go@1.21/libexec/src/runtime/panic.go:914 +0x21f
github.com/brimdata/zed/runtime/sam/expr/coerce.ToNumeric[...]({{0x28c6610?, 0x36dcd00?}, 0x0?, 0xc00052cf40?})
    /Users/phil/work/zed/runtime/sam/expr/coerce/coerce.go:53 +0x125
github.com/brimdata/zed/runtime/sam/expr.toInt(...)
    /Users/phil/work/zed/runtime/sam/expr/eval.go:355
github.com/brimdata/zed/runtime/sam/expr.(*Add).Eval(0xc000571230, {0x4ab35c48?, 0xc00052cf40?}, {{0x28c6610?, 0x36dcd00?}, 0x0?, 0x1011285?})
    /Users/phil/work/zed/runtime/sam/expr/eval.go:412 +0x385
github.com/brimdata/zed/runtime/sam/op/yield.(*Op).Pull(0xc000571260, 0x5?)
    /Users/phil/work/zed/runtime/sam/op/yield/yield.go:31 +0x432
github.com/brimdata/zed/runtime/sam/op.(*Single).Pull(0xc000510e70, 0x20)
    /Users/phil/work/zed/runtime/sam/op/mux.go:134 +0x2b
github.com/brimdata/zed/runtime/sam/op.(*Catcher).Pull(0x3cbfa68?, 0x10?)
    /Users/phil/work/zed/runtime/sam/op/catcher.go:28 +0x62
github.com/brimdata/zed/runtime/exec.(*Query).Pull(0x4ab35b10?, 0xd8?)
    /Users/phil/work/zed/runtime/exec/query.go:59 +0x3e
github.com/brimdata/zed/zbuf.CopyPuller({0x4ab35b10, 0xc000510cf0}, {0x28c0420, 0xc000571290})
    /Users/phil/work/zed/zbuf/batch.go:162 +0x4d
github.com/brimdata/zed/cli/zq.(*Command).Run(0xc00012ea80, {0xc0000dc010, 0x1, 0x1})
    /Users/phil/work/zed/cli/zq/command.go:162 +0x79e
github.com/brimdata/zed/pkg/charm.path.run({0xc0000c2350?, 0x1, 0x1}, {0xc0000dc010?, 0x1, 0x0?})
    /Users/phil/work/zed/pkg/charm/path.go:11 +0x79
github.com/brimdata/zed/pkg/charm.(*Spec).ExecRoot(0x100874b?, {0xc0000dc010, 0x1, 0x1})
    /Users/phil/work/zed/pkg/charm/charm.go:63 +0x3f
main.main()
    /Users/phil/work/zed/cmd/zq/main.go:11 +0x5b

I confirmed via binary search that that commit 19b2eb5 (associated with the changes in #4719) was when this panic started. At the prior commit:

$ zq -version
Version: v1.14.0-28-g05fdd90a

$ zq 'yield null +1'
1