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

Using randint builtin causes panic when both limits are given #1856

Open
1 task done
MrOverlord opened this issue Nov 10, 2024 · 0 comments · May be fixed by #1861
Open
1 task done

Using randint builtin causes panic when both limits are given #1856

MrOverlord opened this issue Nov 10, 2024 · 0 comments · May be fixed by #1861

Comments

@MrOverlord
Copy link
Contributor

MrOverlord commented Nov 10, 2024

Running the following script

var xd = 9223372036854775808 # 1 + signed 64 bit integer max
echo (randint $xd)           # this works fine
echo (randint 0 $xd)         # this should be equivalent to the line above

results in

11786879508667618912
panic: interface conversion: vals.Num is int, not *big.Int

goroutine 1 [running]:
src.elv.sh/pkg/eval.randint({0xc00020e160, 0x2, 0x0?})
	src.elv.sh/pkg/eval/builtin_fn_num.go:378 +0x6f1
reflect.Value.call({0x608cee3ef780?, 0x608cee478288?, 0x608cee476e00?}, {0x608cee2e26bf, 0x4}, {0xc000204360, 0x2, 0x2?})
	reflect/value.go:581 +0xca6
reflect.Value.Call({0x608cee3ef780?, 0x608cee478288?, 0x608cee3c1e80?}, {0xc000204360?, 0x608cee476e00?, 0x7c155a971db8?})
	reflect/value.go:365 +0xb9
src.elv.sh/pkg/eval.(*goFn).Call(0xc0001d2230, 0xc000222100, {0xc00020e0c0, 0x2, 0x608cee3ec440?}, 0xc000204330)
	src.elv.sh/pkg/eval/go_fn.go:247 +0xa30
src.elv.sh/pkg/eval.(*formOp).exec(0xc000040480, 0xc000222100)
	src.elv.sh/pkg/eval/compile_effect.go:297 +0x373
src.elv.sh/pkg/eval.(*pipelineOp).exec.func1({0x608cee47d3e0?, 0xc000040480?}, 0xc000202130)
	src.elv.sh/pkg/eval/compile_effect.go:120 +0x53
src.elv.sh/pkg/eval.(*pipelineOp).exec(0xc00007e680, 0xc000222080)
	src.elv.sh/pkg/eval/compile_effect.go:134 +0x96e
src.elv.sh/pkg/eval.chunkOp.exec({{0x42, 0x4f}, {0xc0000345c0, 0x1, 0x1}}, 0xc000222080)
	src.elv.sh/pkg/eval/compile_effect.go:32 +0x6c
src.elv.sh/pkg/eval.outputCaptureOp.exec({{0x41, 0x50}, {0x608cee47d420, 0xc0000b47b0}}, 0xc000222000)
	src.elv.sh/pkg/eval/compile_value.go:373 +0xb2
src.elv.sh/pkg/eval.compoundOp.exec({{0x41, 0x50}, 0x0, {0xc0000345b0, 0x1, 0x1}}, 0xc000222000)
	src.elv.sh/pkg/eval/compile_value.go:74 +0x75
src.elv.sh/pkg/eval.(*formOp).exec(0xc000040500, 0xc000222000)
	src.elv.sh/pkg/eval/compile_effect.go:274 +0x232
src.elv.sh/pkg/eval.(*pipelineOp).exec.func1({0x608cee47d3e0?, 0xc000040500?}, 0xc000202110)
	src.elv.sh/pkg/eval/compile_effect.go:120 +0x53
src.elv.sh/pkg/eval.(*pipelineOp).exec(0xc00007e6c0, 0xc000040580)
	src.elv.sh/pkg/eval/compile_effect.go:134 +0x96e
src.elv.sh/pkg/eval.chunkOp.exec({{0x0, 0x51}, {0xc0000b44b0, 0x3, 0x3}}, 0xc000040580)
	src.elv.sh/pkg/eval/compile_effect.go:32 +0x6c
src.elv.sh/pkg/eval.nsOp.prepare.func1()
	src.elv.sh/pkg/eval/compiler.go:77 +0x22
src.elv.sh/pkg/eval.(*Evaler).Eval(0xc0000be000, {{0xc00002a120, 0x26}, {0xc0000d2000, 0x51}, 0x1}, {{0x608cee480978, 0xc0000aa050}, {0xc0000120d8, 0x3, ...}, ...})
	src.elv.sh/pkg/eval/eval.go:343 +0x518
src.elv.sh/pkg/shell.evalInTTY({0xc000122088, 0xc000122090, 0xc000122098}, 0xc0000be000, {0x0, 0x0}, {{0xc00002a120, 0x26}, {0xc0000d2000, 0x51}, ...})
	src.elv.sh/pkg/shell/shell.go:191 +0x1ff
src.elv.sh/pkg/shell.script(0xc0000be000, {0xc000122088, 0xc000122090, 0xc000122098}, {0xc000138010?, 0x0?, 0x0?}, 0xc0001cfc75)
	src.elv.sh/pkg/shell/script.go:65 +0x425
src.elv.sh/pkg/shell.(*Program).Run(0xc0001e0270, {0xc000122088, 0xc000122090, 0xc000122098}, {0xc000138010, 0x1, 0x1})
	src.elv.sh/pkg/shell/shell.go:90 +0x32d
src.elv.sh/pkg/prog.composite.Run({0xc00015a960?, 0xc0001cfe18?, 0x608cee0aceea?}, {0xc000122088, 0xc000122090, 0xc000122098}, {0xc000138010, 0x1, 0x1})
	src.elv.sh/pkg/prog/prog.go:192 +0x117
src.elv.sh/pkg/prog.Run({0xc000122088, 0xc000122090, 0xc000122098}, {0xc000138000, 0x2, 0x2}, {0x608cee47e3e8, 0xc000124510})
	src.elv.sh/pkg/prog/prog.go:158 +0x4c7
main.main()
	src.elv.sh/cmd/withpprof/elvish/main.go:17 +0x188

Output of "elvish -version"

0.21.0+archlinux1

Code of Conduct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ❓Triage
Development

Successfully merging a pull request may close this issue.

1 participant