Subject: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)

From: Dima Kogan <[email-masked]>
Date: Fri, 25 Sep 2015 01:13:15 -0700

Eli Zaretskii <[email-masked]> writes:

>> From: Dima Kogan <[email-masked]>
>> Date: Thu, 24 Sep 2015 17:05:12 -0700
>> 
>> Main question of this bug report so far:
>> 
>>   Is there a way to put a watchpoint on a lisp object?
>
> Theoretically, yes.

Hi. I just came back to this, figured out how to (semi-manually) put in
a watchpoint, and this watchpoint told me what's resetting the font
cache: the garbage collector. The backtrace in question:

    0x00000000005d2172 in compact_font_cache_entry (entry=24121763) at alloc.c:5313
    #0  0x00000000005d2172 in compact_font_cache_entry (entry=24121763) at alloc.c:5313
    #1  0x00000000005d221b in compact_font_caches () at alloc.c:5339
    #2  0x00000000005d2742 in garbage_collect_1 (end=0x7ffcdb166830) at alloc.c:5515
    #3  0x00000000005d2e1d in Fgarbage_collect () at alloc.c:5720
    #4  0x000000000054eb21 in maybe_gc () at lisp.h:4515
    #5  0x00000000005f638c in Ffuncall (nargs=3, args=0x7ffcdb166988) at eval.c:2584

    Lisp Backtrace:
    "Automatic GC" (0x0)
    "map-keymap" (0xdb166990)
    "keymap-canonicalize" (0xdb166f38)
    "x-create-frame" (0xdb1678a0)
    "x-create-frame-with-faces" (0xdb167dd8)
    0x12b9d80 PVEC_COMPILED
    "apply" (0xdb168450)
    "frame-creation-function" (0xdb1689f0)
    "make-frame" (0xdb168f40)
    "make-frame-on-display" (0xdb1694a8)
    "server-create-window-system-frame" (0xdb169a78)
    "server-process-filter" (0xdb169ff8)
    Hardware watchpoint 24: ((struct Lisp_Cons *) 0x1701190)->u.cdr

As a test I asked gdb to never drop fonts in the gc by acting as if
drop==0 in compact_font_cache_entry(), and that made the leak in this
bug go away. Clearly that's not a fix, but it's evidence that the
understanding of the problem is correct, so progress is being made.