Subject: 29.0.50; ASAN error in make check

From: Gerd Möllmann <[email-masked]>
Date: Tue, 30 Aug 2022 09:44:02 +0200

In GNU Emacs 29.0.50 (build 1, aarch64-apple-darwin21.6.0, NS
 appkit-2113.60 Version 12.5.1 (Build 21G83)) of 2022-08-30 built on
 Mini.fritz.box
Repository revision: f9250c5ebc1730bf3bed4382549433f52f7ef9ca
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2113
System Description:  macOS 12.5.1

Configured using:
 'configure --cache-file /Users/gerd/tmp/config.cache.master
 --with-native-compilation'

Make check when built with ASAN runs into several problems looking like
this today

  GEN      src/keymap-tests.log
/bin/sh: line 1: 69339 Abort trap: 6           HOME=/nonexistent LANG=C EMACS_TEST_DIRECTORY=/Users/gerd/emacs/master/test "../src/emacs" --module-assertions --no-init-file --no-site-file --no-site-lisp -L ":." -l ert -l src/fns-tests --batch --eval '(ert-run-tests-batch-and-exit (quote (not (or (tag :expensive-test) (tag :unstable)))))' > src/fns-tests.log 2>&1
=================================================================
==69339==ERROR: AddressSanitizer: attempting double-free on 0x000109a11180 in thread T0:
    #0 0x105047c94 in wrap_free+0x98 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x3fc94)
    #1 0x102630978 in rpl_free free.c:48
    #2 0x102462010 in xfree alloc.c:810
    #3 0x1024b5044 in do_one_unbind eval.c
    #4 0x1024a9d30 in unbind_to eval.c:3780
    #5 0x1025002f8 in read0 lread.c:4357
    #6 0x1024f71f0 in read_internal_start lread.c:2568
    #7 0x1024f6e4c in Fread lread.c:2477
    #8 0x1024b3348 in funcall_subr eval.c:3052
    #9 0x1024b2f5c in funcall_general eval.c:2960
    #10 0x1024add38 in Ffuncall eval.c:3014
    #11 0x1024f5e54 in call1 lisp.h:3239
    #12 0x1024f5bb0 in readevalloop lread.c:2317
    #13 0x1024f22d4 in Fload lread.c
    #14 0x1024b33c4 in funcall_subr eval.c:3060
    #15 0x10251d174 in exec_byte_code bytecode.c:809
    #16 0x1024b7378 in fetch_and_exec_byte_code eval.c:3101
    #17 0x1024b3908 in funcall_lambda eval.c:3173
    #18 0x1024b1f64 in apply_lambda eval.c:3123
    #19 0x1024aa46c in eval_sub eval.c
    #20 0x1024b1654 in Feval eval.c:2375
    #21 0x1023c2e5c in top_level_2 keyboard.c:1141
    #22 0x1024aee0c in internal_condition_case eval.c:1497
    #23 0x1023c2de0 in top_level_1 keyboard.c:1149
    #24 0x1024ae34c in internal_catch eval.c:1220
    #25 0x1023a718c in command_loop keyboard.c:1109
    #26 0x1023a6f70 in recursive_edit_1 keyboard.c:719
    #27 0x1023a76d0 in Frecursive_edit keyboard.c:802
    #28 0x1023a353c in main emacs.c:2517
    #29 0x1033b9088 in start+0x204 (dyld:arm64e+0x5088)

0x000109a11180 is located 0 bytes inside of 1536-byte region [0x000109a11180,0x000109a11780)
freed by thread T0 here:
    #0 0x105047ddc in wrap_realloc+0x9c (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x3fddc)
    #1 0x102461fd4 in lrealloc alloc.c:1376
    #2 0x102461f38 in xrealloc alloc.c:790
    #3 0x1024622b0 in xpalloc alloc.c:914
    #4 0x102502840 in grow_read_buffer lread.c:2590
    #5 0x1024ff504 in read0 lread.c:4131
    #6 0x1024f71f0 in read_internal_start lread.c:2568
    #7 0x1024f6e4c in Fread lread.c:2477
    #8 0x1024b3348 in funcall_subr eval.c:3052
    #9 0x1024b2f5c in funcall_general eval.c:2960
    #10 0x1024add38 in Ffuncall eval.c:3014
    #11 0x1024f5e54 in call1 lisp.h:3239
    #12 0x1024f5bb0 in readevalloop lread.c:2317
    #13 0x1024f22d4 in Fload lread.c
    #14 0x1024b33c4 in funcall_subr eval.c:3060
    #15 0x10251d174 in exec_byte_code bytecode.c:809
    #16 0x1024b7378 in fetch_and_exec_byte_code eval.c:3101
    #17 0x1024b3908 in funcall_lambda eval.c:3173
    #18 0x1024b1f64 in apply_lambda eval.c:3123
    #19 0x1024aa46c in eval_sub eval.c
    #20 0x1024b1654 in Feval eval.c:2375
    #21 0x1023c2e5c in top_level_2 keyboard.c:1141
    #22 0x1024aee0c in internal_condition_case eval.c:1497
    #23 0x1023c2de0 in top_level_1 keyboard.c:1149
    #24 0x1024ae34c in internal_catch eval.c:1220
    #25 0x1023a718c in command_loop keyboard.c:1109
    #26 0x1023a6f70 in recursive_edit_1 keyboard.c:719
    #27 0x1023a76d0 in Frecursive_edit keyboard.c:802
    #28 0x1023a353c in main emacs.c:2517
    #29 0x1033b9088 in start+0x204 (dyld:arm64e+0x5088)

previously allocated by thread T0 here:
    #0 0x105047b58 in wrap_malloc+0x94 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x3fb58)
    #1 0x102461e6c in lmalloc alloc.c:1361
    #2 0x102461f98 in xrealloc alloc.c:788
    #3 0x1024622b0 in xpalloc alloc.c:914
    #4 0x102502840 in grow_read_buffer lread.c:2590
    #5 0x1024ff504 in read0 lread.c:4131
    #6 0x1024f71f0 in read_internal_start lread.c:2568
    #7 0x1024f6e4c in Fread lread.c:2477
    #8 0x1024b3348 in funcall_subr eval.c:3052
    #9 0x1024b2f5c in funcall_general eval.c:2960
    #10 0x1024add38 in Ffuncall eval.c:3014
    #11 0x1024f5e54 in call1 lisp.h:3239
    #12 0x1024f5bb0 in readevalloop lread.c:2317
    #13 0x1024f22d4 in Fload lread.c
    #14 0x1024b33c4 in funcall_subr eval.c:3060
    #15 0x10251d174 in exec_byte_code bytecode.c:809
    #16 0x1024b7378 in fetch_and_exec_byte_code eval.c:3101
    #17 0x1024b3908 in funcall_lambda eval.c:3173
    #18 0x1024b1f64 in apply_lambda eval.c:3123
    #19 0x1024aa46c in eval_sub eval.c
    #20 0x1024b1654 in Feval eval.c:2375
    #21 0x1023c2e5c in top_level_2 keyboard.c:1141
    #22 0x1024aee0c in internal_condition_case eval.c:1497
    #23 0x1023c2de0 in top_level_1 keyboard.c:1149
    #24 0x1024ae34c in internal_catch eval.c:1220
    #25 0x1023a718c in command_loop keyboard.c:1109
    #26 0x1023a6f70 in recursive_edit_1 keyboard.c:719
    #27 0x1023a76d0 in Frecursive_edit keyboard.c:802
    #28 0x1023a353c in main emacs.c:2517
    #29 0x1033b9088 in start+0x204 (dyld:arm64e+0x5088)

SUMMARY: AddressSanitizer: double-free (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x3fc94) in wrap_free+0x98
==69339==ABORTING
Fatal error 6: Aborted