Subject: Re: bug#46824: 28.0.50; nativecomp crash with cl-block/cl-defun

From: Pip Cet <[email-masked]>
Date: Sun, 28 Feb 2021 06:13:59 +0000

On Sun, Feb 28, 2021 at 12:35 AM Aaron Jensen <[email-masked]> wrote:
> This originally came from straight.el. It exhibited by attempting to
> invoke something as a function that was not a function, causing an
> error. In narrowing the repro down, it started to crash. It can probably
> get more narrow than this, but pretty much everything I try to
> change/tweak causes it to no longer crash.
>

First, I can reproduce it, so if further debug information is
required, I can probably help.

At first glance, it looks like we're calling _setjmp through a
function pointer without telling gcc that it is a function that may
return twice. This causes gcc to generate code which assumes the stack
frame is unchanged between the two returns of _setjmp, when it
actually isn't, leading to a segfault after the second return.

It used to be the case that all (well, most ...) variables in a
function that calls _setjmp had to be marked volatile to avoid this.
The current way of avoiding the problem is to use gcc's __attribute__
to tell gcc a function may return twice. We're not doing either, so we
run into the stack corruption problem.

Andrea, is it possible to modify the code so _setjmp is called
directly rather than through a function pointer?

Pip