Subject: bug#79200: 31.0.50; Duplicated elements for '#<marker at' in buffer-undo-list

From: Gerd Möllmann <[email-masked]>
Date: Sun, 10 Aug 2025 06:55:45 +0200

Pip Cet <[email-masked]> writes:

>> - record_marker_adjustments undo.c:127
>>   - record_delete record_delete:187
>>     + casify_region casify_region:555
>>     + adjust_after_replace adjust_after_replace:1408
>>     + replace_range replace_range:1639
>>     + del_range_2 del_range_2:2030
>>     + record_change record_change:201
>>
>> where record_marker_adjustments puts basically all present markers in a
>> buffer's undo list. del_range_2 I would interpret that any text deletion
>> might do that.
>
> I think it may make more sense to find out who goes around creating
> markers and not cleaning up after them. But I suspect many places cannot
> easily be fixed because the markers might be exposed to Lisp.

Probably. Good question is how to find these places, especially when
they are created in Lisp :-/.

>
>> I think a garbage-collect with the old GC will clean up the undo list
>> eventually by calling compact_undo_list. With MPS, that doesn't work.
>> The cleanup in compact_undo_list cannot be used because MPS's weak
>> objects and GC work completely differently.
>
> That's my understanding, too. And it means that this probably isn't
> horribly important to fix on the master branch. On feature/igc, it looks
> like something has to be done.
>
>> At the moment I'm a bit out of ideas. Waiting for a divine inspiration,
>> so to speak.
>
> Maybe some markers could be marked at creation time as not being
> important enough to be recorded in the undo list? I'm not really sure
> which markers are being recorded and which need to be for undo to work.

Might be possible but also requires to find where the markers are
created, find out if they are nver required for undo, and so on.