Skip to content

internal/core/toposort: panic involving IndexToString #3698

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

Closed
mvdan opened this issue Jan 23, 2025 · 1 comment
Closed

internal/core/toposort: panic involving IndexToString #3698

mvdan opened this issue Jan 23, 2025 · 1 comment
Assignees
Labels

Comments

@mvdan
Copy link
Member

mvdan commented Jan 23, 2025

exec cue eval input.cue

exec cue def input.cue

-- input.cue --
package p

import "list"

_cfg: {
	[VN=string]: {
		active: true
		name: VN
	}
	cfg0: {
		index: 1
	}
}
_topics: [
	"foo1", 
	"foo2", 
	"foo3", 
	"foo4", 
	"foo5", 
	"foo6", 
	"foo7", 
	"foo8", 
	"foo9", 
	"foo10", 
]

out: list.FlattenN([
	for _ in _cfg.cfg0 for topic in _topics {
		[
			{f: "a-\(topic)"},
			{f: "b-\(topic)"},
			{f: "c-\(topic)"},
			{f: "d-\(topic)"},
			{f: "e-\(topic)" },
			{f: "f-\(topic)" },
		]
	},
], 1)

As of 17c5d0b:

> exec cue eval input.cue
[stderr]
panic: runtime error: index out of range [121] with length 121

goroutine 1 gp=0xc000002380 m=8 mp=0xc000580008 [running]:
panic({0x1028580?, 0xc00003a498?})
	/home/mvdan/tip/src/runtime/panic.go:806 +0x168 fp=0xc00051e4a8 sp=0xc00051e3f8 pc=0x47a628
runtime.goPanicIndex(0x79, 0x79)
	/home/mvdan/tip/src/runtime/panic.go:115 +0x74 fp=0xc00051e4e8 sp=0xc00051e4a8 pc=0x43fdb4
cuelang.org/go/internal/core/runtime.(*index).IndexToString(0xc00051e548?, 0x478651?)
	/home/mvdan/src/c/cue/internal/core/runtime/index.go:94 +0xaa fp=0xc00051e520 sp=0xc00051e4e8 pc=0x7a8d6a
cuelang.org/go/internal/core/runtime.(*Runtime).IndexToString(0x5d?, 0xc00051e640?)
	/home/mvdan/src/c/cue/internal/core/runtime/index.go:25 +0x16 fp=0xc00051e540 sp=0xc00051e520 pc=0x7a86d6
cuelang.org/go/internal/core/adt.(*OpContext).IndexToString(0xc0001517d0?, 0xc00051e5e0?)
	<autogenerated>:1 +0x24 fp=0xc00051e560 sp=0xc00051e540 pc=0x745484
cuelang.org/go/internal/core/adt.Feature.RawString(0x2ac980?, {0x124ebe8?, 0xc0003730e0?})
	/home/mvdan/src/c/cue/internal/core/adt/feature.go:130 +0x37 fp=0xc00051e580 sp=0xc00051e560 pc=0x72e5f7
cuelang.org/go/internal/core/toposort.VertexFeatures(0xc0003730e0, 0xc00021a0a0)
	/home/mvdan/src/c/cue/internal/core/toposort/vertex.go:396 +0x45 fp=0xc00051e8f8 sp=0xc00051e580 pc=0x760be5
cuelang.org/go/internal/core/export.VertexFeatures(0xc00051e978?, 0x417d8f?)
	/home/mvdan/src/c/cue/internal/core/export/toposort.go:33 +0x19 fp=0xc00051e918 sp=0xc00051e8f8 pc=0x777e99
cuelang.org/go/internal/core/export.(*exporter).structComposite(0xc0000e0370, 0xc00021a0a0, {0x0, 0x0, 0x104d200?})
	/home/mvdan/src/c/cue/internal/core/export/value.go:427 +0x348 fp=0xc00051eaa8 sp=0xc00051e918 pc=0x77c888
[...]
> exec cue def input.cue
[stdout]
package p

import "list"
[...]
@mvdan mvdan added the panic label Jan 23, 2025
@cuematthew cuematthew self-assigned this Jan 24, 2025
@cuematthew
Copy link
Contributor

A smaller repro is:

import "list"
list.Repeat([{x: 5}], 1000)

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

No branches or pull requests

2 participants