GNU bug report logs -
#75754
styled_format stack usage/GC protection
Previous Next
Reported by: Pip Cet <pipcet <at> protonmail.com>
Date: Wed, 22 Jan 2025 10:20:01 UTC
Severity: normal
Done: Pip Cet <pipcet <at> protonmail.com>
Bug is archived. No further changes may be made.
Full log
Message #88 received at 75754-done <at> debbugs.gnu.org (full text, mbox):
> Date: Mon, 03 Feb 2025 21:02:17 +0000
> From: Pip Cet <pipcet <at> protonmail.com>
> Cc: eggert <at> cs.ucla.edu, 75754-done <at> debbugs.gnu.org
>
> "Eli Zaretskii" <eliz <at> gnu.org> writes:
>
> >> Date: Thu, 23 Jan 2025 23:58:41 +0000
> >> From: Pip Cet <pipcet <at> protonmail.com>
> >> Cc: eggert <at> cs.ucla.edu, 75754 <at> debbugs.gnu.org
> >>
> >> 1. Reload format_start and format (and end, and format0) after every
> >> call which might have GC'd. If you think we should do this, please
> >> tell me whether lisp_string_width can GC.
> >
> > It can, if called with the last argument 'true' (because
> > find_automatic_composition calls into Lisp). Currently, we call it
> > with 'false', so it cannot.
> >
> >> More importantly, assuming it doesn't, document this in every
> >> function in the call tree starting at lisp_string_width so we don't
> >> accidentally change it.
> >>
> >> 2. memcpy the format string. Two-liner, more likely to fix the bug for
> >> good than (1), wastes more memory (since sa_avail has been negative
> >> since we entered the function, this is xmalloc'd memory).
> >>
> >> 3. replace format by a ptrdiff_t and all instances of *format by
> >> SREF (args[0], index). Faster than 2, but many changes hurting
> >> readability.
> >
> > I prefer (2), I think. Assuming it indeed fixes the problem.
>
> I had to modify it slightly to copy the final NUL character (no harm
> done if it isn't used, but it does appear to be relied upon in a few
> places).
>
> Pushed now. Please test
Thanks, the test I wrote now passes, so I've installed it.
> 2. the crash tests need to be installed once we have a way of presenting
> "Emacs crashed" messages nicely for ERT tets. Alternatively, just wait
> a few weeks; people who run new test suites on old Emacs versions can
> expect the occasional crash.
Does this mean you didn't want me to install the test? It doesn't
crash.
This bug report was last modified 162 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.