Subject: Re: bug#61507: 29.0.60; "free(): invalid pointer" on latest emacs-29 commit when loading init.el

From: Simon Pugnet <[email-masked]>
Date: Tue, 14 Feb 2023 15:04:17 +0000

Po Lu <[email-masked]> writes:
> Simon Pugnet <[email-masked]> writes:
>
>> I've just built Emacs from commit
>> 4bb27a5ca93f8269d9cd4b85fd948176304236eb on the emacs-29 branch and 
>> it
>> fails to launch with the following message when loading my init.el
>> file: -
>>
>> free(): invalid pointer
>> Fatal error 6: Aborted
>> [...]
>
> Will you please run Emacs on top of some kind of memory error 
> checker
> and see if that shows the problem's cause?
>
> I.E. with valgrind's memcheck:
>
>   valgrind /path/to/emacs
>
> it should complain about a double free.

I believe this has already been resolved by Gregory's patch, however 
here's what I see when running with valgrind: -

==203263== Invalid free() / delete / delete[] / realloc()
==203263==    at 0x484426F: free (vg_replace_malloc.c:872)
==203263==    by 0x32563B: safe_free (lisp.h:5385)
==203263==    by 0x32563B: apply_lambda (eval.c:3109)
==203263==    by 0x323921: eval_sub (eval.c:2588)
==203263==    by 0x326510: internal_lisp_condition_case (eval.c:1428)
==203263==    by 0x323FB9: eval_sub (eval.c:2449)
==203263==    by 0x3242AC: Fprogn (eval.c:436)
==203263==    by 0x323FB9: eval_sub (eval.c:2449)
==203263==    by 0x326510: internal_lisp_condition_case (eval.c:1428)
==203263==    by 0x323FB9: eval_sub (eval.c:2449)
==203263==    by 0x3242AC: Fprogn (eval.c:436)
==203263==    by 0x323FB9: eval_sub (eval.c:2449)
==203263==    by 0x3242AC: Fprogn (eval.c:436)
==203263==  Address 0x20987025 is 5 bytes inside a block of size 4,096 
alloc'd
==203263==    at 0x4841888: malloc (vg_replace_malloc.c:381)
==203263==    by 0x2F97B1: lmalloc (alloc.c:1365)
==203263==    by 0x2F97B1: xmalloc (alloc.c:755)
==203263==    by 0x2F97B1: allocate_vector_block (alloc.c:3003)
==203263==    by 0x2F97B1: allocate_vector_from_block (alloc.c:3066)
==203263==    by 0x2F97B1: allocate_vectorlike (alloc.c:3340)
==203263==    by 0x2F9B0F: allocate_pseudovector (alloc.c:3417)
==203263==    by 0x2F9B0F: allocate_buffer (alloc.c:3428)
==203263==    by 0x2B7D62: Fget_buffer_create.part.0 (buffer.c:566)
==203263==    by 0x1803AE: ensure_echo_area_buffers (xdisp.c:12155)
==203263==    by 0x186B14: with_echo_area_buffer (xdisp.c:12194)
==203263==    by 0x1B3230: set_message (xdisp.c:12840)
==203263==    by 0x1B3230: message3_nolog (xdisp.c:11952)
==203263==    by 0x1B34A7: message3 (xdisp.c:11893)
==203263==    by 0x318259: Fmessage (editfns.c:3151)
==203263==    by 0x318259: Fmessage (editfns.c:3119)
==203263==    by 0xE0BF4A3: 
F6c6f61642d776974682d636f64652d636f6e76657273696f6e_load_with_code_conversion_0 
(in 
/storage/Work/personal/emacs/native-lisp/29.0.60-349da14f/preloaded/mule-3352613d-1fec1ce7.eln)
==203263==    by 0x320265: Ffuncall (eval.c:2995)
==203263==    by 0x354F06: call4 (lisp.h:3269)
==203263==    by 0x354F06: Fload (lread.c:1484)

Kind regards,

-- 
Simon Pugnet
https://www.polaris64.net/