Subject: bug#74547: 31.0.50; igc: assertion failed in buffer.c

From: Gerd Möllmann <[email-masked]>
Date: Wed, 27 Nov 2024 07:54:35 +0100

Óscar Fuentes <[email-masked]> writes:

> While editing a .dart file with lsp-mode.

Thanks Oscar. That's a difficult one.

> #3  0x00005555559c1384 in mps_lib_assert_fail
>     (condition=0x555555a4a157 "size > 0", line=579, file=0x555555a47782 "buffer.c")
>     at /home/oscar/dev/other/mps/code/mpsliban.c:87
> #4  BufferFill
> #5  0x00005555559f2da0 in amcSegFix (seg=0x7fffb820d070, ss=0x7fffffff9fc0, refIO=0x7fffffff99d0)
>         trace = <optimized out>
> #6  0x0000555555990b8c in _mps_fix2 (mps_ss=0x7fffffff9fc8, mps_ref_io=0x7fffffff9a10)
>         res = <optimized out>
> #7  0x0000555555903cac in fix_lisp_obj (ss=0x7fffffff9fc8, pobj=0x7fff89f0e000)
>     at ../../emacs/src/igc.c:998
>         res = 32767
>         client = 0x7fff93f2f7d0
>         base = 0x7fff93f2f7d0
>         p = 0x7fff89f0e000
> --Type <RET> for more, q to quit, c to continue without paging--
>         word = 140735675561940
>         tag = 4
>         _ss = 0x7fffffff9fc8
>         _mps_zs = 22
>         _mps_ufs = 549755846664
>         _mps_wt = 32768
>         _mps_w = 133143986160
> #8  0x0000555555904160 in fix_array (ss=0x7fffffff9fc8, array=0x7fff89f0e000, n=6)
>     at ../../emacs/src/igc.c:1233
>         res = 30
>         i = 0
>         _ss = 0x7fffffff9fc8
>         _mps_zs = 22
>         _mps_ufs = 549755813896
>         _mps_wt = <optimized out>
>         _mps_w = 133143986160
> #9  0x000055555590674b in fix_vectorlike (ss=0x7fffffff9fc8, v=0x7fff89f0dff0)
>     at ../../emacs/src/igc.c:1974
>         res = 32767
>         size = 6
>         _ss = 0x7fffffff9fc8
>         _mps_zs = 22
>         _mps_ufs = 549755813896
>         _mps_wt = <optimized out>
>         _mps_w = 133143986160
> #10 0x0000555555908d53 in fix_vector (ss=0x7fffffff9fc8, v=0x7fff89f0dff0)
> --Type <RET> for more, q to quit, c to continue without paging--
>     at ../../emacs/src/igc.c:2646
>         obj_ = 0x7fff89f0dff0
>         res = 0
>         _ss = 0x7fffffff9fc8
>         _mps_zs = 22
>         _mps_ufs = 549755813896
>         _mps_wt = <optimized out>
>         _mps_w = 133143986160
> #11 0x00005555559061d4 in dflt_scan_obj
>     (ss=0x7fffffff9fc8, base_start=0x7fff89f0dff0,
>     base_limit=0x7fff89f0f000, closure=0x0)

I've stripped the rest of the backtrace because it's probably not
too relevant.

What Emacs is doing here is allocate a cons, which triggers a GC step
because the allocation point needs more memory. In this GC step, we
scans a memory area containing a vector (or vectorlike) containing 6
elements. The first element is a string for which MPS_FIX1 says it needs
to be passed to MPS_FIX2, but MPS_FIX2 aborts.

I have no idea why that is. I've added Pip in CC, maybe he has ideas.

> In GNU Emacs 31.0.50 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo
>  version 1.18.2) of 2024-11-25 built on sky
> Repository revision: fad5e872ca05e45afa42ad5fc77b6890c051e4a6
> Repository branch: scratch/igc
> Windowing system distributor 'The X.Org Foundation', version 11.0.12101014
> System Description: Debian GNU/Linux trixie/sid
>
> Configured using:
>  'configure CPPFLAGS=-I/home/oscar/lib/mps/include
>  LDFLAGS=-L/home/oscar/lib/mps/lib --with-native-compilation
>  --with-tree-sitter --without-toolkit-scroll-bars --with-x-toolkit=lucid
>  --with-modules --without-imagemagick --with-mps=yes
>  --enable-checking=yes,glyphs --enable-check-lisp-object-type
>  'CFLAGS=-O0 -g3''

Could you please configure --with-mps=debug? That uses the debug version
of MPS which is more picky, but slower. Also,
--enable-checking=igc_debug is probably better. IIRC, that's not on by
default, and we probably don't need the other checks.

Maybe we some further hints that way.