pdf-raku/Font-FreeType-raku

`t/10metrics_5x7bdf.t` inexplicitly dying in `available-fixed-sizes` invocation.

Closed this issue · 3 comments

Tryed back as far as Rakudo-2013-12. Segfaulting on raw invocation of `get-available-sizes':

david@pc:~/git/Font-FreeType-raku$ rakudo-gdb-m -I . t/10metrics_5x7bdf.t 
================================================================================================
This is Rakudo running in the  debugger, which often allows the user to generate useful back-
traces to debug or report issues in Rakudo, the MoarVM backend or the currently running code.

This Rakudo version is 2024.04.100.g.5.d.6.a.7.dfca built on MoarVM version 2024.04.5.gdbdfb.3999,
running on debian (12.bookworm) / linux

Type `bt full` to generate a backtrace if applicable, type `q` to quit or `help` for help.
------------------------------------------------------------------------------------------------
Reading symbols from /home/david/git/rakudo/install/bin/rakudo-m...
Starting program: /home/david/git/rakudo/install/bin/rakudo-m -I . t/10metrics_5x7bdf.t
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff72836c0 (LWP 53550)]
1..1899
ok 1 - FreeType.face returns an object
ok 2 - FreeType.face returns face object
ok 3 - $face.num-faces
ok 4 - $face.face-index
ok 5 - there is no postscript name
ok 6 - $face->family-name() is right
ok 7 - no style name, defaults to "Regular"
ok 8 - $face.has-glyph-names
ok 9 - $face.has-horizontal-metrics
ok 10 - $face.has-kerning
ok 11 - $face.has-reliable-glyph-names
ok 12 - $face.has-vertical-metrics
ok 13 - $face.is-bold
ok 14 - $face.is-fixed-width
ok 15 - $face.is-italic
ok 16 - $face.is-scalable
ok 17 - $face.is-sfnt
ok 18 - $face.num-glyphs
ok 19 - units-per-em() undef
ok 20 - underline position undef
ok 21 - underline thickness undef
ok 22 - ascender undef
ok 23 - descender undef
ok 24 - BDF files have a single fixed size

Thread 1 "rakudo-m" received signal SIGSEGV, Segmentation fault.
MVMP6int_get_int (tc=0x4a172020180, st=0x4a1727774d0, root=0x4a179250f90, 
    data=0x50009) at src/6model/reprs/P6int.c:94
94	        case 16: return ((MVMP6intBody *)data)->value.i16;
(gdb) bt
#0  MVMP6int_get_int (tc=0x4a172020180, st=0x4a1727774d0, root=0x4a179250f90, 
    data=0x50009) at src/6model/reprs/P6int.c:94
#1  0x00007ffff789cfab in get_attribute (tc=0x4a172020180, st=<optimized out>, 
    root=<optimized out>, data=0x4a179250fa8, class_handle=<optimized out>, 
    name=<optimized out>, hint=-1, result_reg=0x4a172482d30, kind=4)
    at src/6model/reprs/CStruct.c:551
#2  0x00007ffff782100d in MVM_interp_run (tc=0x4a172020180, 
    initial_invoke=0x4a1727774d0, 
    initial_invoke@entry=0x7ffff794cb90 <toplevel_initial_invoke>, 
    invoke_data=0x4a1727774d0, 
    invoke_data@entry=0x7ffff794cb90 <toplevel_initial_invoke>, 
    outer_runloop=0x50009, outer_runloop@entry=0x0) at src/core/interp.c:1923
#3  0x00007ffff794dc05 in MVM_vm_run_file (
    instance=instance@entry=0x4a172010000, 
    filename=filename@entry=0x555555559520 "/home/david/git/rakudo/install/share/perl6/runtime/perl6.moarvm") at src/moar.c:505
#4  0x0000555555555608 in main (argc=<optimized out>, argv=<optimized out>)
    at src/vm/moar/runner/main.c:480
(gdb) 

I'm not sure why it's trying to fetch an i16. num-sizes is i32. Also something seems to have happened to the data offset on the stack between get_attribute and MVMP6int_get_int.

Actually, it's dying a bit later on the first attribute fetch from the FT_Bitmap_Size size struct.

use Test;
plan 59 + 4 * 1 + 1836 * 1;
use Font::FreeType;

my Font::FreeType $ft .= new;
# Load the BDF file.
my $bdf = $ft.face: 't/fonts/5x7.bdf';

# Test getting the set of fixed sizes available.
is $bdf.num-fixed-sizes, 1, 'BDF files have a single fixed size';
my $fixed-size = $bdf.fixed-sizes[0];
note "still alive...";
is($fixed-size.width, 5, 'fixed size width');

Fixed in 0.5.7