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

From: Eli Zaretskii <[email-masked]>
Date: Sat, 06 Mar 2021 20:48:47 +0200

> From: Andrea Corallo <[email-masked]>
> Cc: [email-masked], [email-masked]
> Date: Sat, 06 Mar 2021 18:31:05 +0000
> 
> > ;;; subr-x.el --- extra Lisp functions  -*- lexical-binding:t -*-
> >
> > (defun internal--build-bindings (bindings)
> >   "Check and build conditional value forms for BINDINGS."
> >   (let ((prev-var t))
> >     (mapcar (lambda (binding)
> >               (let ((binding (internal--build-binding binding prev-var)))
> >                 (setq prev-var (car binding))
> >                 binding))
> >             bindings)))
> >
> > Interestingly, if I remove the first line, there's no crash.  So
> > lexical-binding has something to do with this.
> >
> > I cannot see what could trigger the crash.  The fact that 'binding' is
> > used both as an argument and as the variable which is bound to the
> > return value, perhaps?
> >
> > Let me know if you want the C reproducer for this minimal file.
> 
> Yes please.

Attached below.

When compiled with -O2 and linked against libgccjit, it crashes with
the following backtrace:

  Program received signal SIGSEGV, Segmentation fault.
  0x70f5ac3e in libgccjit-0!_Z17gimple_build_callP9tree_nodejz ()
     from D:\usr\bin\libgccjit-0.dll
  (gdb) bt
  #0  0x70f5ac3e in libgccjit-0!_Z17gimple_build_callP9tree_nodejz ()
     from D:\usr\bin\libgccjit-0.dll
  #1  0x7190fa7b in libgccjit-0!_ZN19evrp_range_analyzer5leaveEP15basic_block_def () from D:\usr\bin\libgccjit-0.dll
  #2  0x71910eef in libgccjit-0!_Z36stmt_uses_0_or_null_in_undefined_wayP6gimple () from D:\usr\bin\libgccjit-0.dll
  #3  0x710fba2c in libgccjit-0!_Z16execute_one_passP8opt_pass ()
     from D:\usr\bin\libgccjit-0.dll
  #4  0x710fc171 in libgccjit-0!_Z16execute_one_passP8opt_pass ()
     from D:\usr\bin\libgccjit-0.dll
  #5  0x710fc181 in libgccjit-0!_Z16execute_one_passP8opt_pass ()
     from D:\usr\bin\libgccjit-0.dll
  #6  0x710fc1ad in libgccjit-0!_Z17execute_pass_listP8functionP8opt_pass ()
     from D:\usr\bin\libgccjit-0.dll
  #7  0x70e3770d in libgccjit-0!_ZN11cgraph_node6expandEv ()
     from D:\usr\bin\libgccjit-0.dll
  #8  0x70e386c9 in libgccjit-0!_ZN12symbol_table15output_weakrefsEv ()
     from D:\usr\bin\libgccjit-0.dll
  #9  0x70e3a6f1 in libgccjit-0!_ZN12symbol_table25finalize_compilation_unitEv
      () from D:\usr\bin\libgccjit-0.dll
  #10 0x711bc551 in libgccjit-0!_ZN5timer3popE12timevar_id_t ()
     from D:\usr\bin\libgccjit-0.dll
  #11 0x71b29e4c in libgccjit-0!_ZN6toplev4mainEiPPc ()
     from D:\usr\bin\libgccjit-0.dll
  #12 0x70da78ca in libgccjit-0!_ZN3gcc3jit8playback7context7compileEv ()
     from D:\usr\bin\libgccjit-0.dll
  #13 0x70d9b836 in libgccjit-0!_ZN3gcc3jit9recording7context7compileEv ()
     from D:\usr\bin\libgccjit-0.dll
  #14 0x70d8e193 in libgccjit-0!gcc_jit_context_compile ()
     from D:\usr\bin\libgccjit-0.dll
  #15 0x00445f16 in main ()