Skip to content

freetype crashes occasionally in GlyphAdvance #17

@fhs

Description

@fhs

I'm using the default font at @12pt. I generated a core dump and looked at it with the delve debugger. It seems it crashed when computing GlyphAdvance of 0 (U+0030) but I can't reproduce it. I'm guessing it crashed due to some internal state.

Anyway, I think we should look into moving to golang.org/x/image/font/sfnt rather than spend time debugging freetype.

panic: runtime error: index out of range

goroutine 29 [running, locked to thread]:
panic(0x66e0c0, 0x8f96d0)
        /home/big/go/src/runtime/panic.go:565 +0x2c5 fp=0xc0002c3668 sp=0xc0002c35d8 pc=0x42cbf5
runtime.panicindex()
        /home/big/go/src/runtime/panic.go:44 +0xfb fp=0xc0002c3698 sp=0xc0002c3668 pc=0x42b8fb
github.com/golang/freetype/truetype.(*GlyphBuf).loadSimple(0xc0000c8300, 0x8d7878, 0xac, 0x214bc, 0x3, 0xc000090370, 0x0, 0x0)
        /home/fhs/go/src/github.com/golang/freetype/truetype/glyph.go:329 +0x60b fp=0xc0002c3748 sp=0xc0002c3698 pc=0x57100b
github.com/golang/freetype/truetype.(*GlyphBuf).load(0xc0000c8300, 0x1001300000000, 0x1000000006cd601, 0x0)
        /home/fhs/go/src/github.com/golang/freetype/truetype/glyph.go:229 +0x32c fp=0xc0002c3888 sp=0xc0002c3748 pc=0x5702cc
github.com/golang/freetype/truetype.(*GlyphBuf).Load(0xc0000c8300, 0xc00000c3c0, 0x130000042b, 0x0, 0xc000178a80, 0xc00019ae80)
        /home/fhs/go/src/github.com/golang/freetype/truetype/glyph.go:102 +0xc4 fp=0xc0002c38c0 sp=0xc0002c3888 pc=0x56fce4
github.com/golang/freetype/truetype.(*face).GlyphAdvance(0xc0000c5800, 0x30, 0x10)
        /home/fhs/go/src/github.com/golang/freetype/truetype/face.go:347 +0x6e fp=0xc0002c3900 sp=0xc0002c38c0 pc=0x56f30e
github.com/ktye/duitdraw.(*pixFace).GlyphAdvance(0xc00004e7e0, 0xc000000030, 0x5d07b4)
        <autogenerated>:1 +0x44 fp=0xc0002c3928 sp=0xc0002c3900 pc=0x5cad74
github.com/ktye/duitdraw.(*Font).StringWidth(0xc000174140, 0x6bf0cc, 0x1, 0x0)
        /home/fhs/go/src/github.com/ktye/duitdraw/font.go:139 +0x72 fp=0xc0002c3970 sp=0xc0002c3928 pc=0x5c82e2
github.com/rjkroege/edwood/internal/frame.(*frameimpl).Init(0xc000214780, 0x14, 0x2a, 0x354, 0x3d, 0xc000454038, 0x1, 0x1)
        /home/fhs/go/src/github.com/rjkroege/edwood/internal/frame/frame.go:321 +0x13f fp=0xc0002c39b8 sp=0xc0002c3970 pc=0x5d052f
main.(*Text).Redraw(0xc000064398, 0x14, 0x2a, 0x354, 0x3d, 0x354, 0x100)
        /home/fhs/go/src/github.com/rjkroege/edwood/text.go:142 +0xe5 fp=0xc0002c3a10 sp=0xc0002c39b8 pc=0x619665
main.(*Text).Resize(0xc000064398, 0x0, 0x2a, 0x354, 0x3d, 0x1, 0x6cd658)
        /home/fhs/go/src/github.com/rjkroege/edwood/text.go:182 +0x1aa fp=0xc0002c3a70 sp=0xc0002c3a10 pc=0x619a1a
main.(*Window).Resize(0xc000064380, 0x0, 0x2a, 0x354, 0x3d, 0x0, 0x47f)
        /home/fhs/go/src/github.com/rjkroege/edwood/wind.go:265 +0x59c fp=0xc0002c3af0 sp=0xc0002c3a70 pc=0x624d3c
main.(*Column).Grow(0xc000240000, 0xc0000a8380, 0x1)
        /home/fhs/go/src/github.com/rjkroege/edwood/col.go:444 +0x6da fp=0xc0002c3c28 sp=0xc0002c3af0 pc=0x5f161a
main.(*Text).Show(0xc0000a8488, 0x480, 0x480, 0xffffffffffffff01)
        /home/fhs/go/src/github.com/rjkroege/edwood/text.go:1205 +0x370 fp=0xc0002c3c70 sp=0xc0002c3c28 pc=0x61fa80
main.openfile(0xc0000a8488, 0xc0002c3e48, 0xb)
        /home/fhs/go/src/github.com/rjkroege/edwood/look.go:665 +0x289 fp=0xc0002c3dd8 sp=0xc0002c3c70 pc=0x60fec9
main.plumblook(0xc00030d860)
        /home/fhs/go/src/github.com/rjkroege/edwood/look.go:235 +0x11b fp=0xc0002c3ea0 sp=0xc0002c3dd8 pc=0x60dd1b
main.mousethread(0xc000110000)
        /home/fhs/go/src/github.com/rjkroege/edwood/acme.go:295 +0x242 fp=0xc0002c3fd8 sp=0xc0002c3ea0 pc=0x5eaf12
runtime.goexit()
        /home/big/go/src/runtime/asm_amd64.s:1337 +0x1 fp=0xc0002c3fe0 sp=0xc0002c3fd8 pc=0x459591
created by main.main
        /home/fhs/go/src/github.com/rjkroege/edwood/acme.go:160 +0x887

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions