Subject: bug#46256: [feature/native-comp] AOT eln files ignored if run from build tree

From: Andrea Corallo <[email-masked]>
Date: Thu, 04 Mar 2021 14:49:47 +0000

Andrea Corallo via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <[email-masked]> writes:

> I'll keep on using it for what I can and see if something pops-up,
> that's still possible.

Exactly...

I've a reproducer that is most luckily due to the same issue you are
observing:

emacs -batch -l comp -f batch-native-compile .../emacs/lisp/progmodes/cc-engine.el

GC kicks-in and we end-up marking #<subr c-string-list-p>, we try then
to mark its compilation unit but we segfault (backtrace below).

Will look more into this as soon as I can.

  Andrea

(gdb) bt
#0  0x081ccce3 in symbol_marked_p (s=0x110a02e0) at alloc.c:3982
#1  0x081d1053 in mark_object (arg=XIL(0x8a15f3008a6e8c0)) at alloc.c:6775
#2  0x081d0fe3 in mark_object (arg=XIL(0xa000000008986f10)) at alloc.c:6754
#3  0x081d107f in mark_object (arg=XIL(0xc000000008a78510)) at alloc.c:6781
#4  0x081d1095 in mark_object (arg=XIL(0x351b38)) at alloc.c:6782
#5  0x081d122c in mark_object (arg=XIL(0xc00000000899b4a0)) at alloc.c:6828
#6  0x081d122c in mark_object (arg=XIL(0xc00000000899b470)) at alloc.c:6828
#7  0x081d122c in mark_object (arg=XIL(0xc00000000899b160)) at alloc.c:6828
#8  0x081d10d9 in mark_object (arg=XIL(0x304c78)) at alloc.c:6785
#9  0x081d122c in mark_object (arg=XIL(0xc000000008935960)) at alloc.c:6828
#10 0x081d122c in mark_object (arg=XIL(0xc000000008935420)) at alloc.c:6828
#11 0x081d10d9 in mark_object (arg=XIL(0x273fa0)) at alloc.c:6785
#12 0x081d0d97 in mark_objects (obj=0x89366f8, n=333) at alloc.c:6575
[...]
#979 0x081d1024 in mark_object (arg=XIL(0xa0000000086cc2c0)) at alloc.c:6766
#980 0x081d0fe3 in mark_object (arg=XIL(0xa00000000884a410)) at alloc.c:6754
#981 0x081d107f in mark_object (arg=XIL(0xacd34d78)) at alloc.c:6781
#982 0x081d122c in mark_object (arg=XIL(0xc0000000086d6260)) at alloc.c:6828
#983 0x081d1095 in mark_object (arg=XIL(0x5f78)) at alloc.c:6782
#984 0x081d122c in mark_object (arg=XIL(0xc0000000b5918910)) at alloc.c:6828
#985 0x081d0fcd in mark_object (arg=XIL(0xa0000000b59188d4)) at alloc.c:6753
#986 0x081d107f in mark_object (arg=XIL(0x51b8)) at alloc.c:6781
#987 0x081cf4cf in mark_object_root_visitor (
    root_ptr=0x8629f6c <buffer_defaults+76>, type=GC_ROOT_BUFFER_LOCAL_DEFAULT,
    data=0x0) at alloc.c:5907
#988 0x081cf3dd in visit_vectorlike_root (visitor=...,
    ptr=0x8629f20 <buffer_defaults>, type=GC_ROOT_BUFFER_LOCAL_DEFAULT)
    at alloc.c:5858
#989 0x081cf40a in visit_buffer_root (visitor=...,
    buffer=0x8629f20 <buffer_defaults>, type=GC_ROOT_BUFFER_LOCAL_DEFAULT)
    at alloc.c:5873
#990 0x081cf428 in visit_static_gc_roots (visitor=...) at alloc.c:5885
#991 0x081cfb2d in garbage_collect () at alloc.c:6105
#992 0x081cf8c0 in maybe_garbage_collect () at alloc.c:6018
#993 0x08200031 in maybe_gc () at lisp.h:5124
#994 0x0820825d in Ffuncall (nargs=2, args=0xbfffbfe0) at eval.c:2993
#995 0x082077b7 in call1 (fn=XIL(0xa000000008a11d18), arg1=XIL(0xc000000008b076f0))
    at eval.c:2869
#996 0x08218858 in mapcar1 (leni=352, vals=0xbfffc0d0, fn=XIL(0xa000000008a11d18),
    seq=XIL(0xc000000008b07cf0)) at fns.c:2742
#997 0x08218e34 in Fmapcar (function=XIL(0xa000000008a11d18),
    sequence=XIL(0xc000000008b07cf0)) at fns.c:2798
#998 0xb425f1c5 in F627974652d636f6d70696c652d726563757273652d746f706c6576656c_byte_compile_recurse_toplevel_0 ()
   from /home/andcor03/emacs2/native-lisp/28.0.50-92e930fb/bytecomp-12882072-bfe84587.eln
#999 0x082087c6 in funcall_subr (subr=0x87ee840, numargs=2, args=0xbfffce40)
    at eval.c:3086
#1000 0x08208375 in Ffuncall (nargs=3, args=0xbfffce38) at eval.c:3009
#1001 0xb4270738 in F627974652d636f6d70696c652d746f706c6576656c2d66696c652d666f726d_byte_compile_toplevel_file_form_0 ()
   from /home/andcor03/emacs2/native-lisp/28.0.50-92e930fb/bytecomp-12882072-bfe84587.eln
#1002 0x0820879f in funcall_subr (subr=0x884a010, numargs=1, args=0xbfffd008)
    at eval.c:3084
#1003 0x08208375 in Ffuncall (nargs=2, args=0xbfffd000) at eval.c:3009
#1004 0xb426dfc8 in F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_43 ()
   from /home/andcor03/emacs2/native-lisp/28.0.50-92e930fb/bytecomp-12882072-bfe84587.eln
#1005 0x0820879f in funcall_subr (subr=0x86c8840, numargs=1, args=0xbfffd1e8)
    at eval.c:3084
#1006 0x08208375 in Ffuncall (nargs=2, args=0xbfffd1e0) at eval.c:3009
#1007 0xb426eddc in F627974652d636f6d70696c652d66726f6d2d627566666572_byte_compile_from_buffer_0 ()
   from /home/andcor03/emacs2/native-lisp/28.0.50-92e930fb/bytecomp-12882072-bfe84587.eln
#1008 0x0820879f in funcall_subr (subr=0x8849e50, numargs=1, args=0xbfffd438)
    at eval.c:3084
#1009 0x08208375 in Ffuncall (nargs=2, args=0xbfffd430) at eval.c:3009
#1010 0xb426b91a in F627974652d636f6d70696c652d66696c65_byte_compile_file_0 ()
   from /home/andcor03/emacs2/native-lisp/28.0.50-92e930fb/bytecomp-12882072-bfe84587.eln
#1011 0x082087c6 in funcall_subr (subr=0x8849dd0, numargs=1, args=0xbfffd608)
    at eval.c:3086
#1012 0x08208375 in Ffuncall (nargs=2, args=0xbfffd600) at eval.c:3009
#1013 0x0825e5b4 in exec_byte_code (bytestr=XIL(0x8000000008815760),
    vector=XIL(0xa0000000086b1828), maxdepth=make_fixnum(16),
    args_template=make_fixnum(257), nargs=1, args=0xbfffded0) at bytecode.c:632
#1014 0x08208c03 in fetch_and_exec_byte_code (fun=XIL(0xa0000000086b1968),
    syms_left=make_fixnum(257), nargs=1, args=0xbfffdec8) at eval.c:3133
#1015 0x08208fe9 in funcall_lambda (fun=XIL(0xa0000000086b1968), nargs=1,
    arg_vector=0xbfffdec8) at eval.c:3214
#1016 0x082083d7 in Ffuncall (nargs=2, args=0xbfffdec0) at eval.c:3013
#1017 0x08206ca2 in Fapply (nargs=3, args=0xbfffdec0) at eval.c:2592
#1018 0x082086fa in funcall_subr (subr=0x85db400 <Sapply>, numargs=3,
    args=0xbfffdec0) at eval.c:3064
#1019 0x08208375 in Ffuncall (nargs=4, args=0xbfffdeb8) at eval.c:3009
#1020 0x0825e5b4 in exec_byte_code (bytestr=XIL(0x80000000b55aa5f8),
    vector=XIL(0xa0000000089994a0), maxdepth=make_fixnum(14),
    args_template=make_fixnum(385), nargs=1, args=0xbfffe4e0) at bytecode.c:632
#1021 0x08208c03 in fetch_and_exec_byte_code (fun=XIL(0xa0000000089984c8),
    syms_left=make_fixnum(385), nargs=1, args=0xbfffe4d8) at eval.c:3133
#1022 0x08208fe9 in funcall_lambda (fun=XIL(0xa0000000089984c8), nargs=1,
    arg_vector=0xbfffe4d8) at eval.c:3214
#1023 0x082083d7 in Ffuncall (nargs=2, args=0xbfffe4d0) at eval.c:3013
#1024 0xb43033fd in F636f6d702d7370696c6c2d6c6170_comp_spill_lap_0 ()
   from /home/andcor03/emacs2/native-lisp/28.0.50-92e930fb/comp-7672a6ed-2df580e9.eln
#1025 0x0820879f in funcall_subr (subr=0x89984f8, numargs=1, args=0xbfffe6c8)
    at eval.c:3084
#1026 0x08208375 in Ffuncall (nargs=2, args=0xbfffe6c0) at eval.c:3009
#1027 0xb434f53d in F636f6d702d2d6e61746976652d636f6d70696c65_comp__native_compile_0 ()
   from /home/andcor03/emacs2/native-lisp/28.0.50-92e930fb/comp-7672a6ed-2df580e9.eln
#1028 0x08208803 in funcall_subr (subr=0x89a70a8, numargs=1, args=0xbfffe8b0)
    at eval.c:3089
#1029 0x08208375 in Ffuncall (nargs=2, args=0xbfffe8a8) at eval.c:3009
#1030 0xb4350921 in F62617463682d6e61746976652d636f6d70696c65_batch_native_compile_0 ()
   from /home/andcor03/emacs2/native-lisp/28.0.50-92e930fb/comp-7672a6ed-2df580e9.eln
#1031 0x08208785 in funcall_subr (subr=0x89a71a8, numargs=0, args=0xbfffeb18)
    at eval.c:3082
#1032 0x08208375 in Ffuncall (nargs=1, args=0xbfffeb10) at eval.c:3009
#1033 0xb4a2b841 in F636f6d6d616e642d6c696e652d31_command_line_1_0 ()
   from /home/andcor03/emacs2/src/../native-lisp/28.0.50-92e930fb/startup-bbc6ea72-9be7c541.eln
#1034 0x0820879f in funcall_subr (subr=0xb55deb90, numargs=1, args=0xbfffeec8)
    at eval.c:3084
#1035 0x08208375 in Ffuncall (nargs=2, args=0xbfffeec0) at eval.c:3009
#1036 0xb4a2168d in F636f6d6d616e642d6c696e65_command_line_0 ()
   from /home/andcor03/emacs2/src/../native-lisp/28.0.50-92e930fb/startup-bbc6ea72-9be7c541.eln
#1037 0x08208785 in funcall_subr (subr=0xb54eccb0, numargs=0, args=0xbffff0b8)
    at eval.c:3082
#1038 0x08208375 in Ffuncall (nargs=1, args=0xbffff0b0) at eval.c:3009
#1039 0xb4a1c8ce in F6e6f726d616c2d746f702d6c6576656c_normal_top_level_0 ()
   from /home/andcor03/emacs2/src/../native-lisp/28.0.50-92e930fb/startup-bbc6ea72-9be7c541.eln
#1040 0x08206353 in eval_sub (form=XIL(0xc0000000b565b170)) at eval.c:2481
#1041 0x082059ee in Feval (form=XIL(0xc0000000b565b170), lexical=XIL(0))
    at eval.c:2313
#1042 0x081391f5 in top_level_2 () at keyboard.c:1103
#1043 0x08203347 in internal_condition_case (bfun=0x81391cc <top_level_2>,
    handlers=XIL(0x78), hfun=0x8138ab4 <cmd_error>) at eval.c:1448
#1044 0x08139268 in top_level_1 (ignore=XIL(0)) at keyboard.c:1111
#1045 0x082029e7 in internal_catch (tag=XIL(0xa410), func=0x81391fd <top_level_1>,
    arg=XIL(0)) at eval.c:1198
#1046 0x081390d6 in command_loop () at keyboard.c:1072
#1047 0x08138666 in recursive_edit_1 () at keyboard.c:720
#1048 0x08138841 in Frecursive_edit () at keyboard.c:789
#1049 0x08134e4a in main (argc=7, argv=0xbffff5f4) at emacs.c:2095

Lisp Backtrace:
"Automatic GC" (0x0)
0x8a11d18 PVEC_COMPILED
"byte-compile-recurse-toplevel" (0xbfffce40)
"byte-compile-toplevel-file-form" (0xbfffd008)
0x86c8840 PVEC_SUBR
"byte-compile-from-buffer" (0xbfffd438)
"byte-compile-file" (0xbfffd608)
0x86b1968 PVEC_COMPILED
"apply" (0xbfffdec0)
"comp-spill-lap-function" (0xbfffe4d8)
"comp-spill-lap" (0xbfffe6c8)
"comp--native-compile" (0xbfffe8b0)
"batch-native-compile" (0xbfffeb18)
"command-line-1" (0xbfffeec8)
"command-line" (0xbffff0b8)
"normal-top-level" (0xbffff168)
(gdb)