elves / elvish

Powerful scripting language & versatile interactive shell
https://elv.sh/
BSD 2-Clause "Simplified" License
5.67k stars 300 forks source link

Elvish noDaemon causes panic on cd command #1476

Closed MDr164 closed 2 years ago

MDr164 commented 2 years ago

Using 0.17.0 with the current noDaemon example code produces a stacktrace whenever one tries to change the directory. This might be related to chdir calling into daemon specific functions which are nil and then cause a nil pointer dereference.

goroutine 1 [running]:
src.elv.sh/pkg/sys.DumpStack()
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/sys/dumpstack.go:10 +0x66
src.elv.sh/pkg/shell.handlePanic()
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/shell/interact.go:144 +0x5a
panic({0x764940, 0x990a60})
    /usr/lib/go/src/runtime/panic.go:1038 +0x215
src.elv.sh/pkg/edit.initLocation.func2({0xc000018fe3, 0x8})
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/edit/listing.go:128 +0x58
src.elv.sh/pkg/eval.(*Evaler).Chdir(0xc0001a8000, {0xc000018fe3, 0x8})
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/eval/eval.go:322 +0xd5
src.elv.sh/pkg/eval.cd(0x2, {0xc00005d960, 0x1, 0x1})
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/eval/builtin_fn_fs.go:57 +0xbe
reflect.Value.call({0x758fa0, 0x7bb208, 0x30}, {0x7a5b9d, 0x4}, {0xc0003724e0, 0x2, 0x18})
    /usr/lib/go/src/reflect/value.go:556 +0x845
reflect.Value.Call({0x758fa0, 0x7bb208, 0x748a00}, {0xc0003724e0, 0x2, 0x2})
    /usr/lib/go/src/reflect/value.go:339 +0xc5
src.elv.sh/pkg/eval.(*goFn).Call(0xc0000f72d0, 0xc000301650, {0xc00005d930, 0x1, 0x7}, 0xc0003724b0)
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/eval/go_fn.go:230 +0xb46
src.elv.sh/pkg/eval.(*formOp).exec(0xc000344370, 0xc000301650)
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/eval/compile_effect.go:385 +0x45b
src.elv.sh/pkg/eval.(*pipelineOp).exec.func1({0x7fa7a0, 0xc000344370}, 0xc00005d910)
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/eval/compile_effect.go:120 +0x5a
src.elv.sh/pkg/eval.(*pipelineOp).exec(0xc00006f200, 0xc0003015e0)
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/eval/compile_effect.go:134 +0x692
src.elv.sh/pkg/eval.chunkOp.exec({{0x0, 0xb}, {0xc00005d880, 0x1, 0x1}}, 0xc00000eab0)
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/eval/compile_effect.go:32 +0x112
src.elv.sh/pkg/eval.nsOp.prepare.func1()
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/eval/compiler.go:81 +0x26
src.elv.sh/pkg/eval.(*Evaler).Eval(0xc0001a8000, {{0xc0000192a1, 0x7}, {0xc000018fe0, 0xb}, 0x0}, {{0xc00000eab0, 0x3, 0x3}, 0x7bb1b8, ...})
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/eval/eval.go:408 +0x5a4
src.elv.sh/pkg/shell.evalInTTY(0x1, {0xc0000a2000, 0xc0000a2008, 0xc0000a2010}, {{0xc0000192a1, 0x7}, {0xc000018fe0, 0xb}, 0x0})
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/shell/shell.go:133 +0x185
src.elv.sh/pkg/shell.interact(0xc0001a8000, {0xc0000a2000, 0xc0000a2008, 0xc0000a2010}, 0xc000243cf8)
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/shell/interact.go:130 +0xdbd
src.elv.sh/pkg/shell.Program.Run({0x9e29c8}, {0xc0000a2000, 0xc0000a2008, 0xc0000a2010}, 0xc00011f030, {0xc0000a6010, 0x2, 0x0})
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/shell/shell.go:72 +0x2de
src.elv.sh/pkg/prog.compositeProgram.Run({0xc00009ced0, 0x3, 0xc0000afe20}, {0xc0000a2000, 0xc0000a2008, 0xc0000a2010}, 0x603aef, {0xc0000a6010, 0x0, 0x0})
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/prog/prog.go:154 +0xd3
src.elv.sh/pkg/prog.Run({0xc0000a2000, 0xc0000a2008, 0xc0000a2010}, {0xc0000a6000, 0x2, 0x2}, {0x7fb560, 0xc0000b8168})
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/prog/prog.go:128 +0x406
main.run(...)
    /home/user/go/src/github.com/u-root/u-root/cmds/core/elvish/elvish.go:23
main.main()
    /home/user/go/src/github.com/u-root/u-root/cmds/core/elvish/elvish.go:19 +0x12d

goroutine 19 [chan receive]:
src.elv.sh/pkg/eval.getBlackholeChan.func1()
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/eval/port.go:96 +0x3a
created by src.elv.sh/pkg/eval.getBlackholeChan
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/eval/port.go:95 +0x6f

goroutine 20 [syscall]:
os/signal.signal_recv()
    /usr/lib/go/src/runtime/sigqueue.go:169 +0x98
os/signal.loop()
    /usr/lib/go/src/os/signal/signal_unix.go:24 +0x19
created by os/signal.Notify.func1.1
    /usr/lib/go/src/os/signal/signal.go:151 +0x2c

goroutine 34 [chan receive]:
src.elv.sh/pkg/shell.initTTYAndSignal.func1()
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/shell/shell.go:117 +0x86
created by src.elv.sh/pkg/shell.initTTYAndSignal
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/shell/shell.go:116 +0x9f

goroutine 35 [chan receive]:
src.elv.sh/pkg/cli/prompt.(*Prompt).loop(0xc0001b0310)
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/cli/prompt/prompt.go:77 +0xb6
created by src.elv.sh/pkg/cli/prompt.New
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/cli/prompt/prompt.go:70 +0x1cf

goroutine 36 [chan receive]:
src.elv.sh/pkg/cli/prompt.(*Prompt).loop(0xc0001b03f0)
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/cli/prompt/prompt.go:77 +0xb6
created by src.elv.sh/pkg/cli/prompt.New
    /home/user/go/src/github.com/u-root/u-root/vendor/src.elv.sh/pkg/cli/prompt/prompt.go:70 +0x1cf

runtime error: invalid memory address or nil pointer dereference
krader1961 commented 2 years ago

This should be closed since a fix for it has been merged.