Subject: Re: bug#57751: 29.0.50; crash in GC

From: Sam Steingold <[email-masked]>
Date: Tue, 13 Sep 2022 10:51:12 -0400

Hi Gerd,

Thank you for such an informative reply.

> * Gerd Möllmann <[email-masked]> [2022-09-13 07:20:58 +0200]:
>
> (If you use it for building Emacs, you'll need to "brew install bear",
> or remove the call to bear in the script.  Also, you might want to use
> --elc if you don't use native compilatin.)

I think native compilation is disabled on mac by default.

>   make-emacs --asan

I build my normal Emacs out of the tree, so the source tree is already
clean, thus I just did

--8<---------------cut here---------------start------------->8---
./autogen.sh 
./configure LDFLAGS="-fsanitize=address -fno-omit-frame-pointer" CFLAGS="-g -O0 -fsanitize=address -fno-omit-frame-pointer"
--8<---------------cut here---------------end--------------->8---

which produced

--8<---------------cut here---------------start------------->8---
Configured for 'x86_64-apple-darwin21.6.0'.

  Where should the build process find the source code?    .
  What compiler should emacs be built with?               gcc -g -O0 -fsanitize=address -fno-omit-frame-pointer
  Should Emacs use the GNU version of malloc?             no
    (The GNU allocators don't work with this system configuration.)
  Should Emacs use a relocating allocator for buffers?    no
  Should Emacs use mmap(2) for buffer allocation?         no
  What window system should Emacs use?                    nextstep
  What toolkit should Emacs use?                          none
  Where do we find X Windows header files?                NONE
  Where do we find X Windows libraries?                   NONE
  Does Emacs use -lXaw3d?                                 no
  Does Emacs use -lXpm?                                   no
  Does Emacs use -ljpeg?                                  yes
  Does Emacs use -ltiff?                                  yes
  Does Emacs use a gif library?                           yes -lgif
  Does Emacs use a png library?                           yes -L/usr/local/Cellar/libpng/1.6.37/lib -lpng16 -lz
  Does Emacs use -lrsvg-2?                                no
  Does Emacs use -lwebp?                                  yes
  Does Emacs use -lsqlite3?                               yes
  Does Emacs use cairo?                                   no
  Does Emacs use -llcms2?                                 yes
  Does Emacs use imagemagick?                             no
  Does Emacs use native APIs for images?                  yes (ns)
  Does Emacs support sound?                               no
  Does Emacs use -lgpm?                                   no
  Does Emacs use -ldbus?                                  no
  Does Emacs use -lgconf?                                 no
  Does Emacs use GSettings?                               no
  Does Emacs use a file notification library?             yes (kqueue)
  Does Emacs use access control lists?                    yes 
  Does Emacs use -lselinux?                               no
  Does Emacs use -lgnutls?                                yes
  Does Emacs use -lxml2?                                  yes
  Does Emacs use -lfreetype?                              no
  Does Emacs use HarfBuzz?                                no
  Does Emacs use -lm17n-flt?                              no
  Does Emacs use -lotf?                                   no
  Does Emacs use -lxft?                                   no
  Does Emacs use -lsystemd?                               no
  Does Emacs use -ljansson?                               yes
  Does Emacs use the GMP library?                         yes
  Does Emacs directly use zlib?                           yes
  Does Emacs have dynamic modules support?                yes
  Does Emacs use toolkit scroll bars?                     yes
  Does Emacs support Xwidgets?                            no
  Does Emacs have threading support in lisp?              yes
  Does Emacs support the portable dumper?                 yes
  Does Emacs support legacy unexec dumping?               no
  Which dumping strategy does Emacs use?                  pdumper
  Does Emacs have native lisp compiler?                   no
  Does Emacs use version 2 of the X Input Extension?      no
  Does Emacs generate a smaller-size Japanese dictionary? no
--8<---------------cut here---------------end--------------->8---

and `make' which printed, inter alia,

--8<---------------cut here---------------start------------->8---
  CCLD     temacs
ld: warning: dylib (/usr/local/lib/libtiff.dylib) was built for newer macOS version (12.0) than being linked (11.1)
ld: warning: dylib (/usr/local/lib/libjpeg.dylib) was built for newer macOS version (12.0) than being linked (11.1)
ld: warning: dylib (/usr/local/Cellar/webp/1.2.4/lib/libwebpdemux.dylib) was built for newer macOS version (12.0) than being linked (11.1)
ld: warning: dylib (/usr/local/Cellar/webp/1.2.4/lib/libwebp.dylib) was built for newer macOS version (12.0) than being linked (11.1)
ld: warning: dylib (/usr/local/Cellar/gnutls/3.7.7/lib/libgnutls.dylib) was built for newer macOS version (12.0) than being linked (11.1)
ld: warning: dylib (/usr/local/Cellar/little-cms2/2.13.1_1/lib/liblcms2.dylib) was built for newer macOS version (12.0) than being linked (11.1)
--8<---------------cut here---------------end--------------->8---

> You then run that Emacs in LLDB
>
>   cd src
>   lldb emacs

--8<---------------cut here---------------start------------->8---
lldb) run
Process 18589 launched: '/Users/sdsg/src/emacs/trunk/src/emacs' (x86_64)
emacs(18589,0x101748600) malloc: nano zone abandoned due to inability to preallocate reserved vm space.
2022-09-13 10:48:24.884165-0400 emacs[18589:5791720] SecTaskLoadEntitlements failed error=22 cs_flags=20, pid=18589
2022-09-13 10:48:24.884326-0400 emacs[18589:5791720] SecTaskCopyDebugDescription: emacs[18589]/0#-1 LF=0
2022-09-13 10:48:25.535780-0400 emacs[18589:5791720] SecTaskLoadEntitlements failed error=22 cs_flags=20, pid=18589
2022-09-13 10:48:25.535931-0400 emacs[18589:5791720] SecTaskCopyDebugDescription: emacs[18589]/0#-1 LF=0
2022-09-13 10:48:26.251257-0400 emacs[18589:5791720] SecTaskLoadEntitlements failed error=22 cs_flags=20, pid=18589
2022-09-13 10:48:26.251426-0400 emacs[18589:5791720] SecTaskCopyDebugDescription: emacs[18589]/0#-1 LF=0
2022-09-13 10:48:26.252541-0400 emacs[18589:5791720] SecTaskLoadEntitlements failed error=22 cs_flags=20, pid=18589
2022-09-13 10:48:26.252654-0400 emacs[18589:5791720] SecTaskCopyDebugDescription: emacs[18589]/0#-1 LF=0
2022-09-13 10:48:30.932717-0400 emacs[18589:5791720] SecTaskLoadEntitlements failed error=22 cs_flags=20, pid=18589
2022-09-13 10:48:30.932872-0400 emacs[18589:5791720] SecTaskCopyDebugDescription: emacs[18589]/0#-1 LF=0
2022-09-13 10:48:30.934031-0400 emacs[18589:5791720] SecTaskLoadEntitlements failed error=22 cs_flags=20, pid=18589
2022-09-13 10:48:30.934108-0400 emacs[18589:5791720] SecTaskCopyDebugDescription: emacs[18589]/0#-1 LF=0
Process 18589 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x7ff8c11d6f70)
    frame #0: 0x00000001006dc4e5 emacs`symbol_marked_p(s=0x00007ff8c11d6f70) at alloc.c:4020:14
   4017 {
   4018   return pdumper_object_p (s)
   4019     ? pdumper_marked_p (s)
-> 4020     : s->u.s.gcmarkbit;
   4021 }
   4022
   4023 static void
Target 0: (emacs) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x7ff8c11d6f70)
  * frame #0: 0x00000001006dc4e5 emacs`symbol_marked_p(s=0x00007ff8c11d6f70) at alloc.c:4020:14
    frame #1: 0x00000001006db869 emacs`process_mark_stack(base_sp=0) at alloc.c:6943:10
    frame #2: 0x00000001006d9a79 emacs`mark_object(obj=0x00007ff7bfee99d0) at alloc.c:7035:3
    frame #3: 0x000000010052bf20 emacs`mark_kboards at keyboard.c:13266:4
    frame #4: 0x00000001006d7adc emacs`garbage_collect at alloc.c:6187:3
    frame #5: 0x00000001006d70b6 emacs`maybe_garbage_collect at alloc.c:6090:5
    frame #6: 0x00000001008a6939 emacs`maybe_gc at lisp.h:5564:5
    frame #7: 0x0000000100892632 emacs`exec_byte_code(fun=0x0000621001903355, args_template=257, nargs=1, args=0x000000010d0023e8) at bytecode.c:782:6
    frame #8: 0x00000001007980e7 emacs`fetch_and_exec_byte_code(fun=0x0000621001946b15, args_template=257, nargs=1, args=0x000000010d001da8) at eval.c:3101:10
    frame #9: 0x0000000100790587 emacs`funcall_lambda(fun=0x0000621001946b15, nargs=1, arg_vector=0x000000010d001da8) at eval.c:3173:9
    frame #10: 0x000000010078e703 emacs`funcall_general(fun=0x0000621001946b15, numargs=1, args=0x000000010d001da8) at eval.c:2964:12
    frame #11: 0x000000010077af9b emacs`Ffuncall(nargs=2, args=0x000000010d001da0) at eval.c:3014:21
    frame #12: 0x0000000100785ea5 emacs`Fapply(nargs=2, args=0x000000010d001da0) at eval.c:2642:14
    frame #13: 0x000000010078ff1c emacs`funcall_subr(subr=0x0000000100cc3ca0, numargs=2, args=0x000000010d001da0) at eval.c:3079:9
    frame #14: 0x00000001008928de emacs`exec_byte_code(fun=0x00006210018eb7a5, args_template=385, nargs=2, args=0x000000010d001d10) at bytecode.c:809:14
    frame #15: 0x00000001007980e7 emacs`fetch_and_exec_byte_code(fun=0x00006210018eb7a5, args_template=385, nargs=2, args=0x000000010d001d08) at eval.c:3101:10
    frame #16: 0x0000000100790587 emacs`funcall_lambda(fun=0x00006210018eb7a5, nargs=2, arg_vector=0x000000010d001d08) at eval.c:3173:9
    frame #17: 0x000000010078e703 emacs`funcall_general(fun=0x00006210018eb7a5, numargs=2, args=0x000000010d001d08) at eval.c:2964:12
    frame #18: 0x000000010077af9b emacs`Ffuncall(nargs=3, args=0x000000010d001d00) at eval.c:3014:21
    frame #19: 0x0000000100785ea5 emacs`Fapply(nargs=3, args=0x000000010d001d00) at eval.c:2642:14
    frame #20: 0x000000010078ff1c emacs`funcall_subr(subr=0x0000000100cc3ca0, numargs=3, args=0x000000010d001d00) at eval.c:3079:9
    frame #21: 0x00000001008928de emacs`exec_byte_code(fun=0x0000621001929fc5, args_template=514, nargs=2, args=0x000000010d001d08) at bytecode.c:809:14
    frame #22: 0x00000001007980e7 emacs`fetch_and_exec_byte_code(fun=0x00000001060419d5, args_template=769, nargs=1, args=0x000000010d001b90) at eval.c:3101:10
    frame #23: 0x0000000100790587 emacs`funcall_lambda(fun=0x00000001060419d5, nargs=1, arg_vector=0x000000010d001b90) at eval.c:3173:9
    frame #24: 0x000000010078e703 emacs`funcall_general(fun=0x00000001060419d5, numargs=1, args=0x000000010d001b90) at eval.c:2964:12
    frame #25: 0x000000010077af9b emacs`Ffuncall(nargs=2, args=0x000000010d001b88) at eval.c:3014:21
    frame #26: 0x0000000100785ea5 emacs`Fapply(nargs=2, args=0x000000010d001b88) at eval.c:2642:14
    frame #27: 0x000000010078ff1c emacs`funcall_subr(subr=0x0000000100cc3ca0, numargs=2, args=0x000000010d001b88) at eval.c:3079:9
    frame #28: 0x00000001008928de emacs`exec_byte_code(fun=0x00000001060159ad, args_template=770, nargs=2, args=0x000000010d001be8) at bytecode.c:809:14
    frame #29: 0x00000001007980e7 emacs`fetch_and_exec_byte_code(fun=0x00006210018b3575, args_template=256, nargs=0, args=0x000000010d001938) at eval.c:3101:10
    frame #30: 0x0000000100790587 emacs`funcall_lambda(fun=0x00006210018b3575, nargs=0, arg_vector=0x000000010d001938) at eval.c:3173:9
    frame #31: 0x000000010078e703 emacs`funcall_general(fun=0x00006210018b3575, numargs=0, args=0x000000010d001938) at eval.c:2964:12
    frame #32: 0x0000000100892908 emacs`exec_byte_code(fun=0x00000001061fd5a5, args_template=0, nargs=0, args=0x000000010d001930) at bytecode.c:811:14
    frame #33: 0x00000001007980e7 emacs`fetch_and_exec_byte_code(fun=0x00000001061bfb75, args_template=0, nargs=0, args=0x00007ff7bfefdac0) at eval.c:3101:10
    frame #34: 0x0000000100790587 emacs`funcall_lambda(fun=0x00000001061bfb75, nargs=0, arg_vector=0x00007ff7bfefdac0) at eval.c:3173:9
    frame #35: 0x00000001007858e2 emacs`apply_lambda(fun=0x00000001061bfb75, args=0x0000000000000000, count=(bytes = 128)) at eval.c:3123:9
    frame #36: 0x0000000100772d3f emacs`eval_sub(form=0x0000000106abe8bb) at eval.c:2564:12
    frame #37: 0x0000000100782a67 emacs`Feval(form=0x0000000106abe8bb, lexical=0x0000000000000000) at eval.c:2375:28
    frame #38: 0x000000010052c40b emacs`top_level_2 at keyboard.c:1141:10
    frame #39: 0x000000010077d829 emacs`internal_condition_case(bfun=(emacs`top_level_2 at keyboard.c:1140), handlers=0x0000000000000090, hfun=(emacs`cmd_error at keyboard.c:935)) at eval.c:1497:25
    frame #40: 0x000000010052c300 emacs`top_level_1(ignore=0x0000000000000000) at keyboard.c:1149:5
    frame #41: 0x000000010077bb4d emacs`internal_catch(tag=0x000000000000ea00, func=(emacs`top_level_1 at keyboard.c:1146), arg=0x0000000000000000) at eval.c:1220:25
    frame #42: 0x00000001004e6984 emacs`command_loop at keyboard.c:1109:2
    frame #43: 0x00000001004e6496 emacs`recursive_edit_1 at keyboard.c:719:9
    frame #44: 0x00000001004e737f emacs`Frecursive_edit at keyboard.c:802:3
    frame #45: 0x00000001004debe6 emacs`main(argc=1, argv=0x00007ff7bfeff220) at emacs.c:2517:3
    frame #46: 0x00000001016cd52e dyld`start + 462
--8<---------------cut here---------------end--------------->8---

what do I do next?
Would you like to get on the phone to drive my fingers? ;-)

-- 
Sam Steingold (https://aphar.dreamwidth.org/) on darwin Ns 10.3.2113
https://lastingimpactpsychology.com https://steingoldpsychology.com
https://fairforall.org http://think-israel.org
To be popular with ladies one has to be smart, handsome & rich. Or to be a cat.