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

[Bug] Certain CJK fonts on NixOS causing crash in getRequiredFeature #176

Closed
dweymouth opened this issue Dec 19, 2024 · 4 comments
Closed

Comments

@dweymouth
Copy link

Some users of my Fyne app have reported a crash on NixOS when the app tries to render CJK characters. I have no idea what font it is looking up and I haven't reproduced it myself since I do not have a Nix system, so unfortunately I don't have too much useful info, but the stack trace is:

panic: runtime error: index out of range [0] with length 0

goroutine 170 [running]:
github.com/go-text/typesetting/harfbuzz.getRequiredFeature(...)
	github.com/go-text/[email protected]/harfbuzz/ot_layout.go:247
github.com/go-text/typesetting/harfbuzz.(*otMapBuilder).compile(0x468616e69?, 0xe2b820?, {0xffffffffffffffff, 0xffffffffffffffff})
	github.com/go-text/[email protected]/harfbuzz/ot_map.go:146 +0x12f5
github.com/go-text/typesetting/harfbuzz.(*otShapePlanner).compile(0xc0027bc000, 0xc0027b6710, {0xffffffffffffffff, 0xffffffffffffffff})
	github.com/go-text/[email protected]/harfbuzz/ot_shaper.go:64 +0xaa
github.com/go-text/typesetting/harfbuzz.(*otShapePlan).init0(0xc0027b6710, 0x0?, {{0x0?, 0x0?}, 0x16c4080?, 0xc0?}, {0x0, 0x0, 0x0}, {0xffffffffffffffff, ...})
	github.com/go-text/[email protected]/harfbuzz/ot_shaper.go:173 +0x7d
github.com/go-text/typesetting/harfbuzz.(*shaperOpentype).compile(...)
	github.com/go-text/[email protected]/harfbuzz/ot_shaper.go:777
github.com/go-text/typesetting/harfbuzz.newShapePlan(0xc00279e050, {{0x0?, 0x0?}, 0x13532e8?, 0xc0?}, {0x0, 0x0, 0x0}, {0x0, 0x0, ...})
	github.com/go-text/[email protected]/harfbuzz/shape.go:109 +0x145
github.com/go-text/typesetting/harfbuzz.(*Buffer).newShapePlanCached(0xc0020b6750, 0xc00279e050, {{0x0?, 0xafe497?}, 0xdde760?, 0x0?}, {0x0, 0x0, 0x0}, {0x0, ...})
	github.com/go-text/[email protected]/harfbuzz/shape.go:146 +0x369
github.com/go-text/typesetting/harfbuzz.(*Buffer).Shape(0xc0020b6750, 0xc00279e050, {0x0, 0x0, 0x0})
	github.com/go-text/[email protected]/harfbuzz/shape.go:30 +0x7f
github.com/go-text/typesetting/shaping.(*HarfbuzzShaper).Shape(0xc00135da00, {{0xc0020843c0, 0x28, 0x28}, 0x0, 0x4, 0x0, 0xc001952000, {0x0, 0x0, ...}, ...})
	github.com/go-text/[email protected]/shaping/shaping.go:113 +0x44e
fyne.io/fyne/v2/internal/painter.shapeCallback({0x1067fe0?, 0xc00135da00?}, {{0xc0020843c0, 0x28, 0x28}, 0x0, 0x4, 0x0, 0xc001952000, {0x0, ...}, ...}, ...)
	fyne.io/fyne/[email protected]/internal/painter/font.go:303 +0x7d
fyne.io/fyne/v2/internal/painter.walkString({0x1068ec0, 0xc0003f95c0}, {0xc002c361e0?, 0x0?}, 0x380, {0x1, 0x0, 0x0, 0x0, 0x0, ...}, ...)
	fyne.io/fyne/[email protected]/internal/painter/font.go:294 +0x325
fyne.io/fyne/v2/internal/painter.MeasureString({0x1068ec0?, 0xc0003f95c0?}, {0xc002c361e0?, 0x0?}, 0x0?, {0x1, 0x0, 0x0, 0x0, 0x0, ...})
	fyne.io/fyne/[email protected]/internal/painter/font.go:208 +0x6f
fyne.io/fyne/v2/internal/painter.measureText({0xc002c361e0, 0x54}, 0x41600000, {0x1, 0x0, 0x0, 0x0, 0x0, 0x0}, {0x0, ...})
	fyne.io/fyne/[email protected]/internal/painter/font.go:234 +0xb1
fyne.io/fyne/v2/internal/painter.RenderedTextSize({0xc002c361e0, 0x54}, 0x41600000, {0x1, 0x0, 0x0, 0x0, 0x0, 0x0}, {0x0, ...})
	fyne.io/fyne/[email protected]/internal/painter/font.go:219 +0xfd
fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).RenderedTextSize(0xc002839f80?, {0xc002c361e0?, 0xb9b7f1?}, 0x71a060?, {0x1, 0x0, 0x0, 0x0, 0x0, 0x0}, ...)
	fyne.io/fyne/[email protected]/internal/driver/glfw/driver.go:72 +0x8b
fyne.io/fyne/v2.MeasureText({0xc002c361e0, 0x54}, 0x41600000, {0x1, 0x0, 0x0, 0x0, 0x0, 0x0})
	fyne.io/fyne/[email protected]/text.go:72 +0x98
fyne.io/fyne/v2/widget.(*Hyperlink).syncSegments(0xc0003450e0)
	fyne.io/fyne/[email protected]/widget/hyperlink.go:296 +0x2e9
fyne.io/fyne/v2/widget.(*Hyperlink).SetText(0xc0003450e0, {0xc002c361e0, 0x54})
	fyne.io/fyne/[email protected]/widget/hyperlink.go:196 +0x8f
...
@whereswaldon
Copy link
Member

Hmm, I guess we need a bounds check on https://github.com/go-text/typesetting/blob/v0.2.1/harfbuzz/ot_layout.go#L247

What do you think @benoitkugler? Is this another instance of a corrupt font breaking us?

@benoitkugler
Copy link
Contributor

This bug seems really similar to #140.
From what I understand, the fix (#142) should also apply here, meaning upgrading the version of go-text/typesetting (at least to v0.1.1) should resolve the issue.

@andydotxyz
Copy link
Contributor

Can you check if using Fyne v2.5.3 fixes the issue in your app @dweymouth ? We upgraded a couple of releases ago.

@dweymouth
Copy link
Author

I'd have to wait for my user(s) to report back since I don't have NixOS (and I don't really intend to set up a new VM). I'll close this assuming it will have been solved, and re-open it if needed

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

No branches or pull requests

4 participants